diff options
Diffstat (limited to 'Source/WebCore/rendering/TextPaintStyle.cpp')
-rw-r--r-- | Source/WebCore/rendering/TextPaintStyle.cpp | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/Source/WebCore/rendering/TextPaintStyle.cpp b/Source/WebCore/rendering/TextPaintStyle.cpp index 23988f488..547ca10d8 100644 --- a/Source/WebCore/rendering/TextPaintStyle.cpp +++ b/Source/WebCore/rendering/TextPaintStyle.cpp @@ -26,37 +26,26 @@ #include "config.h" #include "TextPaintStyle.h" +#include "FocusController.h" #include "Frame.h" #include "GraphicsContext.h" +#include "Page.h" #include "PaintInfo.h" #include "RenderStyle.h" #include "RenderText.h" +#include "RenderTheme.h" #include "RenderView.h" #include "Settings.h" namespace WebCore { -TextPaintStyle::TextPaintStyle(ColorSpace colorSpace) - : colorSpace(colorSpace) - , strokeWidth(0) -#if ENABLE(LETTERPRESS) - , useLetterpressEffect(false) -#endif -{ -} - -TextPaintStyle::TextPaintStyle(Color color, ColorSpace colorSpace) - : colorSpace(colorSpace) - , fillColor(color) +TextPaintStyle::TextPaintStyle(const Color& color) + : fillColor(color) , strokeColor(color) - , strokeWidth(0) -#if ENABLE(LETTERPRESS) - , useLetterpressEffect(false) -#endif { } -static Color adjustColorForVisibilityOnBackground(Color textColor, Color backgroundColor) +static Color adjustColorForVisibilityOnBackground(const Color& textColor, const Color& backgroundColor) { int d = differenceSquared(textColor, backgroundColor); // Semi-arbitrarily chose 65025 (255^2) value here after a few tests. @@ -71,28 +60,37 @@ static Color adjustColorForVisibilityOnBackground(Color textColor, Color backgro return textColor.light(); } -TextPaintStyle computeTextPaintStyle(const RenderText& renderer, const RenderStyle& lineStyle, const PaintInfo& paintInfo) +TextPaintStyle computeTextPaintStyle(const Frame& frame, const RenderStyle& lineStyle, const PaintInfo& paintInfo) { - TextPaintStyle paintStyle(lineStyle.colorSpace()); + TextPaintStyle paintStyle; #if ENABLE(LETTERPRESS) paintStyle.useLetterpressEffect = lineStyle.textDecorationsInEffect() & TextDecorationLetterpress; #endif paintStyle.strokeWidth = lineStyle.textStrokeWidth(); - if (paintInfo.forceBlackText()) { - paintStyle.fillColor = Color::black; - paintStyle.strokeColor = Color::black; - paintStyle.emphasisMarkColor = Color::black; + if (paintInfo.forceTextColor()) { + paintStyle.fillColor = paintInfo.forcedTextColor(); + paintStyle.strokeColor = paintInfo.forcedTextColor(); + paintStyle.emphasisMarkColor = paintInfo.forcedTextColor(); return paintStyle; } + + if (lineStyle.insideDefaultButton()) { + Page* page = frame.page(); + if (page && page->focusController().isActive()) { + paintStyle.fillColor = page->theme().systemColor(CSSValueActivebuttontext); + return paintStyle; + } + } + paintStyle.fillColor = lineStyle.visitedDependentColor(CSSPropertyWebkitTextFillColor); bool forceBackgroundToWhite = false; - if (renderer.document().printing()) { + if (frame.document() && frame.document()->printing()) { if (lineStyle.printColorAdjust() == PrintColorAdjustEconomy) forceBackgroundToWhite = true; - if (renderer.frame().settings().shouldPrintBackgrounds()) + if (frame.settings().shouldPrintBackgrounds()) forceBackgroundToWhite = false; } @@ -119,27 +117,27 @@ TextPaintStyle computeTextSelectionPaintStyle(const TextPaintStyle& textPaintSty { paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection); paintSelectedTextSeparately = false; - selectionShadow = paintInfo.forceBlackText() ? nullptr : lineStyle.textShadow(); + selectionShadow = (paintInfo.forceTextColor()) ? nullptr : lineStyle.textShadow(); TextPaintStyle selectionPaintStyle = textPaintStyle; #if ENABLE(TEXT_SELECTION) - Color foreground = paintInfo.forceBlackText() ? Color::black : renderer.selectionForegroundColor(); + Color foreground = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : renderer.selectionForegroundColor(); if (foreground.isValid() && foreground != selectionPaintStyle.fillColor) { if (!paintSelectedTextOnly) paintSelectedTextSeparately = true; selectionPaintStyle.fillColor = foreground; } - Color emphasisMarkForeground = paintInfo.forceBlackText() ? Color::black : renderer.selectionEmphasisMarkColor(); + Color emphasisMarkForeground = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : renderer.selectionEmphasisMarkColor(); if (emphasisMarkForeground.isValid() && emphasisMarkForeground != selectionPaintStyle.emphasisMarkColor) { if (!paintSelectedTextOnly) paintSelectedTextSeparately = true; selectionPaintStyle.emphasisMarkColor = emphasisMarkForeground; } - if (RenderStyle* pseudoStyle = renderer.getCachedPseudoStyle(SELECTION)) { - const ShadowData* shadow = paintInfo.forceBlackText() ? 0 : pseudoStyle->textShadow(); + if (auto* pseudoStyle = renderer.getCachedPseudoStyle(SELECTION)) { + const ShadowData* shadow = paintInfo.forceTextColor() ? nullptr : pseudoStyle->textShadow(); if (shadow != selectionShadow) { if (!paintSelectedTextOnly) paintSelectedTextSeparately = true; @@ -153,7 +151,7 @@ TextPaintStyle computeTextSelectionPaintStyle(const TextPaintStyle& textPaintSty selectionPaintStyle.strokeWidth = strokeWidth; } - Color stroke = paintInfo.forceBlackText() ? Color::black : pseudoStyle->visitedDependentColor(CSSPropertyWebkitTextStrokeColor); + Color stroke = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : pseudoStyle->visitedDependentColor(CSSPropertyWebkitTextStrokeColor); if (stroke != selectionPaintStyle.strokeColor) { if (!paintSelectedTextOnly) paintSelectedTextSeparately = true; @@ -186,12 +184,12 @@ void updateGraphicsContext(GraphicsContext& context, const TextPaintStyle& paint } Color fillColor = fillColorType == UseEmphasisMarkColor ? paintStyle.emphasisMarkColor : paintStyle.fillColor; - if (mode & TextModeFill && (fillColor != context.fillColor() || paintStyle.colorSpace != context.fillColorSpace())) - context.setFillColor(fillColor, paintStyle.colorSpace); + if (mode & TextModeFill && (fillColor != context.fillColor())) + context.setFillColor(fillColor); if (mode & TextModeStroke) { if (paintStyle.strokeColor != context.strokeColor()) - context.setStrokeColor(paintStyle.strokeColor, paintStyle.colorSpace); + context.setStrokeColor(paintStyle.strokeColor); if (paintStyle.strokeWidth != context.strokeThickness()) context.setStrokeThickness(paintStyle.strokeWidth); } |