Allow PaintInfo to carry all PaintBehavior flags
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2013 20:00:52 +0000 (20:00 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jan 2013 20:00:52 +0000 (20:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=106980

Reviewed by Sam Weinig.

PaintInfo has a single boolean for forceBlackText, but I'll be adding additional
paint behaviors that I'd like to access from PaintInfo, so it makes sense for
PaintInfo to just include the set of PaintBehavior flags.

Also add default values in the constructor arguments for rarely used parameters.

No behavior change, no tests.

* rendering/EllipsisBox.cpp:
(WebCore::EllipsisBox::paint): Use the forceBlackText() function.
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paint): Call forceBlackText().
* rendering/PaintInfo.h:
(WebCore::PaintInfo::PaintInfo): Pass PaintBehavior rather than a forceBlackText boolean.
(WebCore::PaintInfo::forceBlackText): Return true if the behavior flags contain PaintBehaviorForceBlackText.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended): Pass PaintBehaviorForceBlackText instead of 'true'
when painting for background-clip: text.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paintLayerContents): Pass PaintBehaviorNormal where we used to pass 'false',
and omit default 0 parameters.
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::renderSubtreeToImageBuffer): PaintBehaviorNormal and remove default params.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139908 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/EllipsisBox.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/PaintInfo.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.cpp

index 01cf716..dbd89f9 100644 (file)
@@ -1,3 +1,34 @@
+2013-01-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Allow PaintInfo to carry all PaintBehavior flags
+        https://bugs.webkit.org/show_bug.cgi?id=106980
+
+        Reviewed by Sam Weinig.
+        
+        PaintInfo has a single boolean for forceBlackText, but I'll be adding additional
+        paint behaviors that I'd like to access from PaintInfo, so it makes sense for
+        PaintInfo to just include the set of PaintBehavior flags.
+        
+        Also add default values in the constructor arguments for rarely used parameters.
+
+        No behavior change, no tests.
+
+        * rendering/EllipsisBox.cpp:
+        (WebCore::EllipsisBox::paint): Use the forceBlackText() function.
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::paint): Call forceBlackText().
+        * rendering/PaintInfo.h:
+        (WebCore::PaintInfo::PaintInfo): Pass PaintBehavior rather than a forceBlackText boolean.
+        (WebCore::PaintInfo::forceBlackText): Return true if the behavior flags contain PaintBehaviorForceBlackText.
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended): Pass PaintBehaviorForceBlackText instead of 'true'
+        when painting for background-clip: text.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::paintLayerContents): Pass PaintBehaviorNormal where we used to pass 'false',
+        and omit default 0 parameters.
+        * rendering/svg/SVGRenderingContext.cpp:
+        (WebCore::SVGRenderingContext::renderSubtreeToImageBuffer): PaintBehaviorNormal and remove default params.
+
 2013-01-16  Tim Horton  <timothy_horton@apple.com>
 
         Add a missing #if to fix the Mac build sans ENABLE_CSS_FILTERS.
index 902df2b..0f03f1d 100644 (file)
@@ -51,7 +51,7 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
         paintSelection(context, paintOffset, style, font);
 
         // Select the correct color for painting the text.
-        Color foreground = paintInfo.forceBlackText ? Color::black : renderer()->selectionForegroundColor();
+        Color foreground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionForegroundColor();
         if (foreground.isValid() && foreground != textColor)
             context->setFillColor(foreground, style->colorSpace());
     }
index 2cb0e27..2fca979 100644 (file)
@@ -553,9 +553,9 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
     Color textStrokeColor;
     Color emphasisMarkColor;
     float textStrokeWidth = styleToUse->textStrokeWidth();
-    const ShadowData* textShadow = paintInfo.forceBlackText ? 0 : styleToUse->textShadow();
+    const ShadowData* textShadow = paintInfo.forceBlackText() ? 0 : styleToUse->textShadow();
 
-    if (paintInfo.forceBlackText) {
+    if (paintInfo.forceBlackText()) {
         textFillColor = Color::black;
         textStrokeColor = Color::black;
         emphasisMarkColor = Color::black;
@@ -597,14 +597,14 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
     const ShadowData* selectionShadow = textShadow;
     if (haveSelection) {
         // Check foreground color first.
-        Color foreground = paintInfo.forceBlackText ? Color::black : renderer()->selectionForegroundColor();
+        Color foreground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionForegroundColor();
         if (foreground.isValid() && foreground != selectionFillColor) {
             if (!paintSelectedTextOnly)
                 paintSelectedTextSeparately = true;
             selectionFillColor = foreground;
         }
 
-        Color emphasisMarkForeground = paintInfo.forceBlackText ? Color::black : renderer()->selectionEmphasisMarkColor();
+        Color emphasisMarkForeground = paintInfo.forceBlackText() ? Color::black : renderer()->selectionEmphasisMarkColor();
         if (emphasisMarkForeground.isValid() && emphasisMarkForeground != selectionEmphasisMarkColor) {
             if (!paintSelectedTextOnly)
                 paintSelectedTextSeparately = true;
@@ -612,7 +612,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
         }
 
         if (RenderStyle* pseudoStyle = renderer()->getCachedPseudoStyle(SELECTION)) {
-            const ShadowData* shadow = paintInfo.forceBlackText ? 0 : pseudoStyle->textShadow();
+            const ShadowData* shadow = paintInfo.forceBlackText() ? 0 : pseudoStyle->textShadow();
             if (shadow != selectionShadow) {
                 if (!paintSelectedTextOnly)
                     paintSelectedTextSeparately = true;
@@ -626,7 +626,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
                 selectionStrokeWidth = strokeWidth;
             }
 
-            Color stroke = paintInfo.forceBlackText ? Color::black : pseudoStyle->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
+            Color stroke = paintInfo.forceBlackText() ? Color::black : pseudoStyle->visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
             if (stroke != selectionStrokeColor) {
                 if (!paintSelectedTextOnly)
                     paintSelectedTextSeparately = true;
index 2781496..fea1d7a 100644 (file)
@@ -52,13 +52,13 @@ typedef HashMap<OverlapTestRequestClient*, IntRect> OverlapTestRequestMap;
  * (tx|ty) is the calculated position of the parent
  */
 struct PaintInfo {
-    PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, bool newForceBlackText,
-              RenderObject* newPaintingRoot, RenderRegion* region, ListHashSet<RenderInline*>* newOutlineObjects,
+    PaintInfo(GraphicsContext* newContext, const IntRect& newRect, PaintPhase newPhase, PaintBehavior newPaintBehavior,
+              RenderObject* newPaintingRoot = 0, RenderRegion* region = 0, ListHashSet<RenderInline*>* newOutlineObjects = 0,
               OverlapTestRequestMap* overlapTestRequests = 0)
         : context(newContext)
         , rect(newRect)
         , phase(newPhase)
-        , forceBlackText(newForceBlackText)
+        , paintBehavior(newPaintBehavior)
         , paintingRoot(newPaintingRoot)
         , renderRegion(region)
         , outlineObjects(newOutlineObjects)
@@ -83,6 +83,8 @@ struct PaintInfo {
         return !paintingRoot || paintingRoot == renderer;
     }
 
+    bool forceBlackText() const { return paintBehavior & PaintBehaviorForceBlackText; }
+
 #if ENABLE(SVG)
     void applyTransform(const AffineTransform& localToAncestorTransform)
     {
@@ -104,7 +106,7 @@ struct PaintInfo {
     GraphicsContext* context;
     IntRect rect;
     PaintPhase phase;
-    bool forceBlackText;
+    PaintBehavior paintBehavior;
     RenderObject* paintingRoot; // used to draw just one element and its visual kids
     RenderRegion* renderRegion;
     ListHashSet<RenderInline*>* outlineObjects; // used to list outlines that should be painted by a block with inline children
index 349e7b4..1c4bde3 100644 (file)
@@ -870,7 +870,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
 
         // Now add the text to the clip.  We do this by painting using a special paint phase that signals to
         // InlineTextBoxes that they should just add their contents to the clip.
-        PaintInfo info(maskImageContext, maskRect, PaintPhaseTextClip, true, 0, paintInfo.renderRegion, 0);
+        PaintInfo info(maskImageContext, maskRect, PaintPhaseTextClip, PaintBehaviorForceBlackText, 0, paintInfo.renderRegion);
         if (box) {
             RootInlineBox* root = box->root();
             box->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrolledPaintRect.y() - box->y()), root->lineTop(), root->lineBottom());
index fd2fc73..4e68e8e 100644 (file)
@@ -3687,7 +3687,7 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
             }
             
             // Paint the background.
-            PaintInfo paintInfo(context, pixelSnappedIntRect(damageRect.rect()), PaintPhaseBlockBackground, false, paintingRootForRenderer, localPaintingInfo.region, 0);
+            PaintInfo paintInfo(context, pixelSnappedIntRect(damageRect.rect()), PaintPhaseBlockBackground, PaintBehaviorNormal, paintingRootForRenderer, localPaintingInfo.region);
             renderer()->paint(paintInfo, paintOffset);
 
             if (useClipRect) {
@@ -3714,7 +3714,7 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
             
             PaintInfo paintInfo(context, pixelSnappedIntRect(clipRectToApply.rect()),
                                 selectionOnly ? PaintPhaseSelection : PaintPhaseChildBlockBackgrounds,
-                                forceBlackText, paintingRootForRenderer, localPaintingInfo.region, 0);
+                                forceBlackText ? PaintBehaviorForceBlackText : PaintBehaviorNormal, paintingRootForRenderer, localPaintingInfo.region);
             renderer()->paint(paintInfo, paintOffset);
             if (!selectionOnly) {
                 paintInfo.phase = PaintPhaseFloat;
@@ -3734,7 +3734,7 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
 
         if (shouldPaintOutline && !outlineRect.isEmpty()) {
             // Paint our own outline
-            PaintInfo paintInfo(context, pixelSnappedIntRect(outlineRect.rect()), PaintPhaseSelfOutline, false, paintingRootForRenderer, localPaintingInfo.region, 0);
+            PaintInfo paintInfo(context, pixelSnappedIntRect(outlineRect.rect()), PaintPhaseSelfOutline, PaintBehaviorNormal, paintingRootForRenderer, localPaintingInfo.region);
             clipToRect(localPaintingInfo.rootLayer, context, localPaintingInfo.paintDirtyRect, outlineRect, DoNotIncludeSelfForBorderRadius);
             renderer()->paint(paintInfo, paintOffset);
             restoreClip(context, localPaintingInfo.paintDirtyRect, outlineRect);
@@ -3770,7 +3770,7 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
             clipToRect(localPaintingInfo.rootLayer, context, localPaintingInfo.paintDirtyRect, damageRect, DoNotIncludeSelfForBorderRadius); // Mask painting will handle clipping to self.
         
         // Paint the mask.
-        PaintInfo paintInfo(context, pixelSnappedIntRect(damageRect.rect()), PaintPhaseMask, false, paintingRootForRenderer, localPaintingInfo.region, 0);
+        PaintInfo paintInfo(context, pixelSnappedIntRect(damageRect.rect()), PaintPhaseMask, PaintBehaviorNormal, paintingRootForRenderer, localPaintingInfo.region);
         renderer()->paint(paintInfo, paintOffset);
         
         if (useClipRect) {
index 041aed4..257e829 100644 (file)
@@ -251,7 +251,7 @@ void SVGRenderingContext::renderSubtreeToImageBuffer(ImageBuffer* image, RenderO
     ASSERT(image);
     ASSERT(image->context());
 
-    PaintInfo info(image->context(), PaintInfo::infiniteRect(), PaintPhaseForeground, 0, 0, 0, 0);
+    PaintInfo info(image->context(), PaintInfo::infiniteRect(), PaintPhaseForeground, PaintBehaviorNormal);
 
     AffineTransform& contentTransformation = currentContentTransformation();
     AffineTransform savedContentTransformation = contentTransformation;