2011-05-12 Levi Weintraub <leviw@chromium.org>
authorleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 May 2011 21:05:13 +0000 (21:05 +0000)
committerleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 May 2011 21:05:13 +0000 (21:05 +0000)
        Reviewed by Eric Seidel.

        Switch paintMask and paintMaskImages off of ints
        https://bugs.webkit.org/show_bug.cgi?id=60578

        Primarily switching paintMask and paintMaskImages to use IntSize and IntRect respectively.
        In the process of that:
         - added an "expand" function to IntRect that allows you to add an IntSize or pair of
           integers to the size portion of an IntRect.
         - changed borderFitAdjust to take an IntRect. It modifies only the x and width attributes.

        No new tests since this refactoring.

        * platform/graphics/IntRect.h:
        (WebCore::IntRect::expand): Added for convenience.
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::paintObject):
        (WebCore::RenderBlock::borderFitAdjust):
        * rendering/RenderBlock.h:
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::paintBoxDecorationsWithSize):
        (WebCore::RenderBox::paintMask):
        (WebCore::RenderBox::paintMaskImages):
        * rendering/RenderBox.h:
        (WebCore::RenderBox::borderFitAdjust):
        * rendering/RenderFieldset.cpp:
        (WebCore::RenderFieldset::paintMask):
        * rendering/RenderFieldset.h:
        * rendering/RenderReplaced.cpp:
        (WebCore::RenderReplaced::paint):
        * rendering/RenderReplica.cpp:
        (WebCore::RenderReplica::paint):
        * rendering/RenderTable.cpp:
        (WebCore::RenderTable::paintObject):
        (WebCore::RenderTable::paintMask):
        * rendering/RenderTable.h:
        * rendering/RenderTableCell.cpp:
        (WebCore::RenderTableCell::paintMask):
        * rendering/RenderTableCell.h:
        * rendering/RenderWidget.cpp:
        (WebCore::RenderWidget::paint):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/IntRect.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderFieldset.cpp
Source/WebCore/rendering/RenderFieldset.h
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderReplica.cpp
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTable.h
Source/WebCore/rendering/RenderTableCell.cpp
Source/WebCore/rendering/RenderTableCell.h
Source/WebCore/rendering/RenderWidget.cpp

index e918e74..23c4323 100644 (file)
@@ -1,3 +1,47 @@
+2011-05-12  Levi Weintraub  <leviw@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        Switch paintMask and paintMaskImages off of ints
+        https://bugs.webkit.org/show_bug.cgi?id=60578
+
+        Primarily switching paintMask and paintMaskImages to use IntSize and IntRect respectively.
+        In the process of that:
+         - added an "expand" function to IntRect that allows you to add an IntSize or pair of
+           integers to the size portion of an IntRect.
+         - changed borderFitAdjust to take an IntRect. It modifies only the x and width attributes.
+
+        No new tests since this refactoring.
+
+        * platform/graphics/IntRect.h:
+        (WebCore::IntRect::expand): Added for convenience.
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintObject):
+        (WebCore::RenderBlock::borderFitAdjust):
+        * rendering/RenderBlock.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintBoxDecorationsWithSize):
+        (WebCore::RenderBox::paintMask):
+        (WebCore::RenderBox::paintMaskImages):
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::borderFitAdjust):
+        * rendering/RenderFieldset.cpp:
+        (WebCore::RenderFieldset::paintMask):
+        * rendering/RenderFieldset.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::paint):
+        * rendering/RenderReplica.cpp:
+        (WebCore::RenderReplica::paint):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::paintObject):
+        (WebCore::RenderTable::paintMask):
+        * rendering/RenderTable.h:
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::paintMask):
+        * rendering/RenderTableCell.h:
+        * rendering/RenderWidget.cpp:
+        (WebCore::RenderWidget::paint):
+
 2011-05-12  Patrick Gansterer  <paroga@webkit.org>
 
         Reviewed by Eric Seidel.
index d2b348b..5527387 100644 (file)
@@ -107,9 +107,12 @@ public:
     // center point.
     IntPoint center() const { return IntPoint(x() + width() / 2, y() + height() / 2); }
 
-    void move(const IntSize& s) { m_location += s; } 
+    void move(const IntSize& size) { m_location += size; } 
     void move(int dx, int dy) { m_location.move(dx, dy); } 
-    
+
+    void expand(const IntSize& size) { m_location += size; }
+    void expand(int dw, int dh) { m_size.expand(dw, dh); }
+
     void shiftXEdgeTo(int edge)
     {
         int delta = edge - x();
index eb0950b..a17a40a 100644 (file)
@@ -2462,7 +2462,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, int tx, int ty)
     }
 
     if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) {
-        paintMask(paintInfo, tx, ty);
+        paintMask(paintInfo, IntSize(tx, ty));
         return;
     }
 
@@ -5595,7 +5595,7 @@ void RenderBlock::adjustForBorderFit(int x, int& left, int& right) const
     }
 }
 
-void RenderBlock::borderFitAdjust(int& x, int& w) const
+void RenderBlock::borderFitAdjust(IntRect& rect) const
 {
     if (style()->borderFit() == BorderFitBorder)
         return;
@@ -5603,19 +5603,19 @@ void RenderBlock::borderFitAdjust(int& x, int& w) const
     // Walk any normal flow lines to snugly fit.
     int left = INT_MAX;
     int right = INT_MIN;
-    int oldWidth = w;
+    int oldWidth = rect.width();
     adjustForBorderFit(0, left, right);
     if (left != INT_MAX) {
         left -= (borderLeft() + paddingLeft());
         if (left > 0) {
-            x += left;
-            w -= left;
+            rect.move(left, 0);
+            rect.expand(-left, 0);
         }
     }
     if (right != INT_MIN) {
         right += (borderRight() + paddingRight());
         if (right < oldWidth)
-            w -= (oldWidth - right);
+            rect.expand(-(oldWidth - right), 0);
     }
 }
 
index 5efd6a9..22a9236 100644 (file)
@@ -360,7 +360,7 @@ private:
     void layoutInlineChildren(bool relayoutChildren, int& repaintLogicalTop, int& repaintLogicalBottom);
     BidiRun* handleTrailingSpaces(BidiRunList<BidiRun>&, BidiContext*);
 
-    virtual void borderFitAdjust(int& x, int& w) const; // Shrink the box in which the border paints if border-fit is set.
+    virtual void borderFitAdjust(IntRect&) const; // Shrink the box in which the border paints if border-fit is set.
 
     virtual void updateBeforeAfterContent(PseudoId);
 
index ff70e0a..0d646a8 100644 (file)
@@ -837,11 +837,11 @@ void RenderBox::paintBoxDecorationsWithSize(PaintInfo& paintInfo, int tx, int ty
     IntRect paintRect = IntRect(tx, ty, width, height);
     // border-fit can adjust where we paint our border and background.  If set, we snugly fit our line box descendants.  (The iChat
     // balloon layout is an example of this).
-    borderFitAdjust(tx, width);
+    borderFitAdjust(paintRect);
 
     // FIXME: Should eventually give the theme control over whether the box shadow should paint, since controls could have
     // custom shadows of their own.
-    paintBoxShadow(paintInfo.context, tx, ty, width, height, style(), Normal);
+    paintBoxShadow(paintInfo.context, paintRect.x(), paintRect.y(), paintRect.width(), paintRect.height(), style(), Normal);
 
     BackgroundBleedAvoidance bleedAvoidance = determineBackgroundBleedAvoidance(paintInfo.context);
 
@@ -870,32 +870,31 @@ void RenderBox::paintBoxDecorationsWithSize(PaintInfo& paintInfo, int tx, int ty
         if (style()->hasAppearance())
             theme()->paintDecorations(this, paintInfo, paintRect);
     }
-    paintBoxShadow(paintInfo.context, tx, ty, width, height, style(), Inset);
+    paintBoxShadow(paintInfo.context, paintRect.x(), paintRect.y(), paintRect.width(), paintRect.height(), style(), Inset);
 
     // The theme will tell us whether or not we should also paint the CSS border.
     if ((!style()->hasAppearance() || (!themePainted && theme()->paintBorderOnly(this, paintInfo, paintRect))) && style()->hasBorder())
-        paintBorder(paintInfo.context, IntRect(tx, ty, width, height), style(), bleedAvoidance);
+        paintBorder(paintInfo.context, paintRect, style(), bleedAvoidance);
 
     if (bleedAvoidance == BackgroundBleedUseTransparencyLayer)
         paintInfo.context->endTransparencyLayer();
 }
 
-void RenderBox::paintMask(PaintInfo& paintInfo, int tx, int ty)
+void RenderBox::paintMask(PaintInfo& paintInfo, IntSize paintOffset)
 {
     if (!paintInfo.shouldPaintWithinRoot(this) || style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask || paintInfo.context->paintingDisabled())
         return;
 
-    int w = width();
-    int h = height();
+    IntRect paintRect = IntRect(toPoint(paintOffset), size());
 
     // border-fit can adjust where we paint our border and background.  If set, we snugly fit our line box descendants.  (The iChat
     // balloon layout is an example of this).
-    borderFitAdjust(tx, w);
+    borderFitAdjust(paintRect);
 
-    paintMaskImages(paintInfo, tx, ty, w, h);
+    paintMaskImages(paintInfo, paintRect);
 }
 
-void RenderBox::paintMaskImages(const PaintInfo& paintInfo, int tx, int ty, int w, int h)
+void RenderBox::paintMaskImages(const PaintInfo& paintInfo, const IntRect& paintRect)
 {
     // Figure out if we need to push a transparency layer to render our mask.
     bool pushTransparencyLayer = false;
@@ -953,7 +952,6 @@ void RenderBox::paintMaskImages(const PaintInfo& paintInfo, int tx, int ty, int
     }
 
     if (allMaskImagesLoaded) {
-        IntRect paintRect = IntRect(tx, ty, w, h);
         paintFillLayers(paintInfo, Color(), style()->maskLayers(), paintRect, BackgroundBleedNone, compositeOp);
         paintNinePieceImage(paintInfo.context, paintRect, style(), style()->maskBoxImage(), compositeOp);
     }
index d73590d..2c98c7f 100644 (file)
@@ -252,7 +252,7 @@ public:
     int computeContentBoxLogicalWidth(int width) const;
     int computeContentBoxLogicalHeight(int height) const;
 
-    virtual void borderFitAdjust(int& /*x*/, int& /*w*/) const { } // Shrink the box in which the border paints if border-fit is set.
+    virtual void borderFitAdjust(IntRect&) const { } // Shrink the box in which the border paints if border-fit is set.
 
     // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end
     // of the containing block.
@@ -345,7 +345,7 @@ public:
 
     virtual void paintObject(PaintInfo&, int /*tx*/, int /*ty*/) { ASSERT_NOT_REACHED(); }
     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
-    virtual void paintMask(PaintInfo&, int tx, int ty);
+    virtual void paintMask(PaintInfo&, IntSize);
     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
 
     // Called when a positioned object moves but doesn't necessarily change size.  A simplified layout is attempted
@@ -409,7 +409,7 @@ protected:
     void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, BackgroundBleedAvoidance = BackgroundBleedNone, CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);
 
     void paintBoxDecorationsWithSize(PaintInfo&, int tx, int ty, int width, int height);
-    void paintMaskImages(const PaintInfo&, int tx, int ty, int width, int height);
+    void paintMaskImages(const PaintInfo&, const IntRect&);
 
 #if PLATFORM(MAC)
     void paintCustomHighlight(int tx, int ty, const AtomicString& type, bool behindText);
index 8de95f6..fd8c500 100644 (file)
@@ -170,31 +170,31 @@ void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     paintBorder(paintInfo.context, IntRect(tx, ty, w, h), style());
 }
 
-void RenderFieldset::paintMask(PaintInfo& paintInfo, int tx, int ty)
+void RenderFieldset::paintMask(PaintInfo& paintInfo, IntSize paintOffset)
 {
     if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
         return;
 
-    int w = width();
-    int h = height();
+    IntRect paintRect = IntRect(toPoint(paintOffset), size());
+    IntSize adjustedSize = size();
     RenderBox* legend = findLegend();
     if (!legend)
-        return RenderBlock::paintMask(paintInfo, tx, ty);
+        return RenderBlock::paintMask(paintInfo, paintOffset);
 
     // FIXME: We need to work with "rl" and "bt" block flow directions.  In those
     // cases the legend is embedded in the right and bottom borders respectively.
     // https://bugs.webkit.org/show_bug.cgi?id=47236
     if (style()->isHorizontalWritingMode()) {
         int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2;
-        h -= yOff;
-        ty += yOff;
+        paintRect.expand(0, -yOff);
+        paintRect.move(0, yOff);
     } else {
         int xOff = (legend->x() > 0) ? 0 : (legend->width() - borderLeft()) / 2;
-        w -= xOff;
-        tx += xOff;
+        paintRect.expand(-xOff, 0);
+        paintRect.move(xOff, 0);
     }
 
-    paintMaskImages(paintInfo, tx, ty, w, h);
+    paintMaskImages(paintInfo, paintRect);
 }
 
 } // namespace WebCore
index 267f352..77e1e73 100644 (file)
@@ -45,7 +45,7 @@ private:
     virtual bool stretchesToMinIntrinsicLogicalWidth() const { return true; }
 
     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
-    virtual void paintMask(PaintInfo&, int tx, int ty);
+    virtual void paintMask(PaintInfo&, IntSize);
 };
 
 inline RenderFieldset* toRenderFieldset(RenderObject* object)
index c27d336..ad9b6af 100644 (file)
@@ -106,7 +106,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
         paintBoxDecorations(paintInfo, tx, ty);
     
     if (paintInfo.phase == PaintPhaseMask) {
-        paintMask(paintInfo, tx, ty);
+        paintMask(paintInfo, IntSize(tx, ty));
         return;
     }
 
index c099d9d..be7939f 100644 (file)
@@ -76,7 +76,7 @@ void RenderReplica::paint(PaintInfo& paintInfo, int tx, int ty)
                                       PaintBehaviorNormal, 0, 0,
                                       RenderLayer::PaintLayerHaveTransparency | RenderLayer::PaintLayerAppliedTransform | RenderLayer::PaintLayerTemporaryClipRects | RenderLayer::PaintLayerPaintingReflection);
     else if (paintInfo.phase == PaintPhaseMask)
-        paintMask(paintInfo, tx, ty);
+        paintMask(paintInfo, IntSize(tx, ty));
 }
 
 } // namespace WebCore
index 5135bee..3188436 100644 (file)
@@ -480,7 +480,7 @@ void RenderTable::paintObject(PaintInfo& paintInfo, int tx, int ty)
         paintBoxDecorations(paintInfo, tx, ty);
 
     if (paintPhase == PaintPhaseMask) {
-        paintMask(paintInfo, tx, ty);
+        paintMask(paintInfo, IntSize(tx, ty));
         return;
     }
 
@@ -573,15 +573,15 @@ void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
         paintBorder(paintInfo.context, rect, style());
 }
 
-void RenderTable::paintMask(PaintInfo& paintInfo, int tx, int ty)
+void RenderTable::paintMask(PaintInfo& paintInfo, IntSize paintOffset)
 {
     if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
         return;
 
-    IntRect rect(tx, ty, width(), height());
+    IntRect rect(toPoint(paintOffset), size());
     subtractCaptionRect(rect);
 
-    paintMaskImages(paintInfo, rect.x(), rect.y(), rect.width(), rect.height());
+    paintMaskImages(paintInfo, rect);
 }
 
 void RenderTable::computePreferredLogicalWidths()
index 01fbca7..08a735a 100644 (file)
@@ -217,7 +217,7 @@ private:
     virtual void paint(PaintInfo&, int tx, int ty);
     virtual void paintObject(PaintInfo&, int tx, int ty);
     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
-    virtual void paintMask(PaintInfo&, int tx, int ty);
+    virtual void paintMask(PaintInfo&, IntSize);
     virtual void layout();
     virtual void computePreferredLogicalWidths();
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int xPos, int yPos, int tx, int ty, HitTestAction);
index 7340261..6ba88fa 100644 (file)
@@ -1023,7 +1023,7 @@ void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     paintBorder(paintInfo.context, IntRect(tx, ty, w, h), style());
 }
 
-void RenderTableCell::paintMask(PaintInfo& paintInfo, int tx, int ty)
+void RenderTableCell::paintMask(PaintInfo& paintInfo, IntSize paintOffset)
 {
     if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
         return;
@@ -1031,11 +1031,8 @@ void RenderTableCell::paintMask(PaintInfo& paintInfo, int tx, int ty)
     RenderTable* tableElt = table();
     if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild())
         return;
-
-    int w = width();
-    int h = height();
    
-    paintMaskImages(paintInfo, tx, ty, w, h);
+    paintMaskImages(paintInfo, IntRect(toPoint(paintOffset), size()));
 }
 
 void RenderTableCell::scrollbarsChanged(bool horizontalScrollbarChanged, bool verticalScrollbarChanged)
index 9884999..f09d1b6 100644 (file)
@@ -143,7 +143,7 @@ private:
     virtual void computeLogicalWidth();
 
     virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
-    virtual void paintMask(PaintInfo&, int tx, int ty);
+    virtual void paintMask(PaintInfo&, IntSize);
 
     virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
index 894d689..684531e 100644 (file)
@@ -258,7 +258,7 @@ void RenderWidget::paint(PaintInfo& paintInfo, int tx, int ty)
         paintBoxDecorations(paintInfo, tx, ty);
 
     if (paintInfo.phase == PaintPhaseMask) {
-        paintMask(paintInfo, tx, ty);
+        paintMask(paintInfo, IntSize(tx, ty));
         return;
     }