Commit b80b4638 authored by leviw@chromium.org's avatar leviw@chromium.org

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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86400 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b22b6131
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.
......@@ -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)) {
......
......@@ -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);
......
......@@ -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;
......
......@@ -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));
}
}
......
......@@ -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
......
......@@ -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);
}
}
......
......@@ -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));
}
}
......
......@@ -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));
}
}
......
......@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment