[GTK] Menu list button doesn't use the text color from the theme
[WebKit-https.git] / Source / WebCore / rendering / TextPaintStyle.cpp
index b398fdd..e1debbb 100644 (file)
 
 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.
@@ -74,9 +60,9 @@ 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;
@@ -91,9 +77,9 @@ TextPaintStyle computeTextPaintStyle(const RenderText& renderer, const RenderSty
     }
 
     if (lineStyle.insideDefaultButton()) {
-        Page* page = renderer.frame().page();
+        Page* page = frame.page();
         if (page && page->focusController().isActive()) {
-            paintStyle.fillColor = renderer.theme().systemColor(CSSValueActivebuttontext);
+            paintStyle.fillColor = page->theme().systemColor(CSSValueActivebuttontext);
             return paintStyle;
         }
     }
@@ -101,10 +87,10 @@ TextPaintStyle computeTextPaintStyle(const RenderText& renderer, const RenderSty
     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;
     }
 
@@ -198,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);
     }