2011-05-12 Levi Weintraub <leviw@chromium.org>
authorleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 May 2011 00:05:12 +0000 (00:05 +0000)
committerleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 May 2011 00:05:12 +0000 (00:05 +0000)
        Reviewed by Simon Fraser.

        Switch paintOutline to use IntRect
        https://bugs.webkit.org/show_bug.cgi?id=60718

        Switching paintOutline to use an IntRect instead of 4 ints.

        No new tests as this is just refactoring.

        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::paintObject):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::paintOutline):
        * rendering/RenderObject.h:
        * rendering/RenderReplaced.cpp:
        (WebCore::RenderReplaced::paint):
        * rendering/RenderTable.cpp:
        (WebCore::RenderTable::paintObject):
        * rendering/svg/RenderSVGContainer.cpp:
        (WebCore::RenderSVGContainer::paint):
        * rendering/svg/RenderSVGImage.cpp:
        (WebCore::RenderSVGImage::paint):
        * rendering/svg/RenderSVGPath.cpp:
        (WebCore::RenderSVGPath::paint):
        * rendering/svg/RenderSVGRoot.cpp:
        (WebCore::RenderSVGRoot::paint):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/svg/RenderSVGContainer.cpp
Source/WebCore/rendering/svg/RenderSVGImage.cpp
Source/WebCore/rendering/svg/RenderSVGPath.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.cpp

index 0a9123746ca28faea95adba3d0ee51689ec850a5..967523adb343ad3da2992e5a859a2e31e4dfc434 100644 (file)
@@ -1,3 +1,32 @@
+2011-05-12  Levi Weintraub  <leviw@chromium.org>
+
+        Reviewed by Simon Fraser.
+
+        Switch paintOutline to use IntRect
+        https://bugs.webkit.org/show_bug.cgi?id=60718
+
+        Switching paintOutline to use an IntRect instead of 4 ints.
+
+        No new tests as this is just refactoring.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintObject):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::paintOutline):
+        * rendering/RenderObject.h:
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::paint):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::paintObject):
+        * rendering/svg/RenderSVGContainer.cpp:
+        (WebCore::RenderSVGContainer::paint):
+        * rendering/svg/RenderSVGImage.cpp:
+        (WebCore::RenderSVGImage::paint):
+        * rendering/svg/RenderSVGPath.cpp:
+        (WebCore::RenderSVGPath::paint):
+        * rendering/svg/RenderSVGRoot.cpp:
+        (WebCore::RenderSVGRoot::paint):
+
 2011-05-12  Anders Carlsson  <andersca@apple.com>
 
         Address review comment by Dan Bernstein.
index a17a40a2b289ebfdffbd8d1127b42ffd6012b7a3..79ae0ffe612fe3eaa976f45a6a22e6c6935168ca 100644 (file)
@@ -2503,7 +2503,7 @@ void RenderBlock::paintObject(PaintInfo& paintInfo, int tx, int ty)
 
     // 5. paint outline.
     if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && hasOutline() && style()->visibility() == VISIBLE)
-        paintOutline(paintInfo.context, tx, ty, width(), height());
+        paintOutline(paintInfo.context, IntRect(tx, ty, width(), height()));
 
     // 6. paint continuation outlines.
     if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseChildOutlines)) {
index 1e2f9a38d1489b8cdddd566ddb29a49944e31c45..7549aab8205892dcf8aa6bdcca0b9b4bb4f3fde8 100644 (file)
@@ -1020,7 +1020,7 @@ void RenderObject::addPDFURLRect(GraphicsContext* context, const IntRect& rect)
     context->setURLForRect(n->document()->completeURL(href), rect);
 }
 
-void RenderObject::paintOutline(GraphicsContext* graphicsContext, int tx, int ty, int w, int h)
+void RenderObject::paintOutline(GraphicsContext* graphicsContext, const IntRect& paintRect)
 {
     if (!hasOutline())
         return;
@@ -1036,19 +1036,17 @@ void RenderObject::paintOutline(GraphicsContext* graphicsContext, int tx, int ty
     if (styleToUse->outlineStyleIsAuto() || hasOutlineAnnotation()) {
         if (!theme()->supportsFocusRing(styleToUse)) {
             // Only paint the focus ring by hand if the theme isn't able to draw the focus ring.
-            paintFocusRing(graphicsContext, tx, ty, styleToUse);
+            paintFocusRing(graphicsContext, paintRect.x(), paintRect.y(), styleToUse);
         }
     }
 
     if (styleToUse->outlineStyleIsAuto() || styleToUse->outlineStyle() == BNONE)
         return;
 
-    tx -= offset;
-    ty -= offset;
-    w += 2 * offset;
-    h += 2 * offset;
+    IntRect adjustedPaintRec = paintRect;
+    adjustedPaintRec.inflate(offset);
 
-    if (h < 0 || w < 0)
+    if (adjustedPaintRec.isEmpty())
         return;
 
 #if !USE(SKIA)
@@ -1059,14 +1057,14 @@ void RenderObject::paintOutline(GraphicsContext* graphicsContext, int tx, int ty
     }
 #endif
 
-    int leftOuter = tx - outlineWidth;
-    int leftInner = tx;
-    int rightOuter = tx + w + outlineWidth;
-    int rightInner = tx + w;
-    int topOuter = ty - outlineWidth;
-    int topInner = ty;
-    int bottomOuter = ty + h + outlineWidth;
-    int bottomInner = ty + h;
+    int leftOuter = adjustedPaintRec.x() - outlineWidth;
+    int leftInner = adjustedPaintRec.x();
+    int rightOuter = adjustedPaintRec.maxX() + outlineWidth;
+    int rightInner = adjustedPaintRec.maxX();
+    int topOuter = adjustedPaintRec.y() - outlineWidth;
+    int topInner = adjustedPaintRec.y();
+    int bottomOuter = adjustedPaintRec.maxY() + outlineWidth;
+    int bottomInner = adjustedPaintRec.maxY();
     
     drawLineForBoxSide(graphicsContext, leftOuter, topOuter, leftInner, bottomOuter, BSLeft, outlineColor, outlineStyle, outlineWidth, outlineWidth);
     drawLineForBoxSide(graphicsContext, leftOuter, topOuter, rightOuter, topInner, BSTop, outlineColor, outlineStyle, outlineWidth, outlineWidth);
index c09a99520c74fef477d27b69c4c3e18bde3ee685..b4f3fec3dbba95a5319f9bac77274b48674ff773 100644 (file)
@@ -792,7 +792,7 @@ protected:
                             Color, EBorderStyle, int adjbw1, int adjbw2, bool antialias = false);
 
     void paintFocusRing(GraphicsContext*, int tx, int ty, RenderStyle*);
-    void paintOutline(GraphicsContext*, int tx, int ty, int w, int h);
+    void paintOutline(GraphicsContext*, const IntRect&);
     void addPDFURLRect(GraphicsContext*, const IntRect&);
 
     virtual IntRect viewRect() const;
index ad9b6aff6c2a940bda54330480025d3eedd71794..d8650b62ccbe8ed080d60a3b7999f7a2686c75eb 100644 (file)
@@ -110,8 +110,9 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
         return;
     }
 
+    IntRect paintRect = IntRect(IntPoint(tx, ty), size());
     if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
-        paintOutline(paintInfo.context, tx, ty, width(), height());
+        paintOutline(paintInfo.context, paintRect);
     
     if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection)
         return;
@@ -135,7 +136,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
         else {
             // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
             paintInfo.context->save();
-            paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(borderRect));
+            paintInfo.context->addRoundedRectClip(style()->getRoundedBorderFor(paintRect));
         }
     }
 
index a54d0b22232d9af58c8b4b5e8fd19b30356992a2..a18916593f70de1a4aca7fec38eb8fc54a35382a 100644 (file)
@@ -529,7 +529,7 @@ void RenderTable::paintObject(PaintInfo& paintInfo, int tx, int ty)
 
     // Paint outline.
     if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && hasOutline() && style()->visibility() == VISIBLE)
-        paintOutline(paintInfo.context, tx, ty, width(), height());
+        paintOutline(paintInfo.context, IntRect(IntPoint(tx, ty), size()));
 }
 
 void RenderTable::subtractCaptionRect(IntRect& rect) const
index d3c481e81086fa9e92b72b73542726e812cdd1c0..ef14848666835e6065023454695e8b2cd316eb05 100644 (file)
@@ -134,7 +134,7 @@ void RenderSVGContainer::paint(PaintInfo& paintInfo, int, int)
     // We should instead disable our clip during PaintPhaseOutline
     if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && style()->visibility() == VISIBLE) {
         IntRect paintRectInParent = enclosingIntRect(localToParentTransform().mapRect(repaintRect));
-        paintOutline(paintInfo.context, paintRectInParent.x(), paintRectInParent.y(), paintRectInParent.width(), paintRectInParent.height());
+        paintOutline(paintInfo.context, paintRectInParent);
     }
 }
 
index 5fff7f77458cdf671b27ea7700e089c11b135bea..50c87c2888d402a6f3ebab79dccc65bf64d212d5 100644 (file)
@@ -137,8 +137,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int)
         }
 
         if (drawsOutline)
-            paintOutline(childPaintInfo.context, static_cast<int>(boundingBox.x()), static_cast<int>(boundingBox.y()),
-                static_cast<int>(boundingBox.width()), static_cast<int>(boundingBox.height()));
+            paintOutline(childPaintInfo.context, IntRect(boundingBox));
     }
 }
 
index 6216de81edc46513fc430b0f97e7f72411813b02..799271edff672df45b840055c436da27b0a63820 100644 (file)
@@ -230,8 +230,7 @@ void RenderSVGPath::paint(PaintInfo& paintInfo, int, int)
         }
 
         if (drawsOutline)
-            paintOutline(childPaintInfo.context, static_cast<int>(boundingBox.x()), static_cast<int>(boundingBox.y()),
-                static_cast<int>(boundingBox.width()), static_cast<int>(boundingBox.height()));
+            paintOutline(childPaintInfo.context, IntRect(boundingBox));
     }
 }
 
index 30f72b9280d0dfdf97117b3bbd8c90928ee2d609..4565c3909c7c36cca9f329ff2074cd343e224985 100644 (file)
@@ -189,7 +189,7 @@ void RenderSVGRoot::paint(PaintInfo& paintInfo, int parentX, int parentY)
     childPaintInfo.context->restore();
 
     if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth() && isVisible)
-        paintOutline(paintInfo.context, borderBoxOriginInContainer.x(), borderBoxOriginInContainer.y(), width(), height());
+        paintOutline(paintInfo.context, IntRect(borderBoxOriginInContainer, size()));
 }
 
 void RenderSVGRoot::destroy()