Skip to content
Permalink
Browse files
2011-05-11 Levi Weintraub <leviw@chromium.org>
        Reviewed by Eric Seidel.

        Switch RenderBoxModelObject::paintBorder to use IntRect instead of four ints
        https://bugs.webkit.org/show_bug.cgi?id=60591

        Switching RenderBoxModelObject::paintBorder to use IntRect instead of four ints representing a rect.

        No new tests since there is no functionality change.

        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::paintBoxDecorations):
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::paintBoxDecorationsWithSize):
        * rendering/RenderBoxModelObject.cpp:
        (WebCore::RenderBoxModelObject::paintBorder):
        * rendering/RenderBoxModelObject.h:
        * rendering/RenderFieldset.cpp:
        (WebCore::RenderFieldset::paintBoxDecorations):
        * rendering/RenderTable.cpp:
        (WebCore::RenderTable::paintBoxDecorations):
        * rendering/RenderTableCell.cpp:
        (WebCore::RenderTableCell::paintBoxDecorations):


Canonical link: https://commits.webkit.org/75929@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
leviw committed May 11, 2011
1 parent 0dee3a8 commit 485a827c3f5b7edbbf368075b83b04d519e6614a
Showing 8 changed files with 67 additions and 43 deletions.
@@ -1,3 +1,28 @@
2011-05-11 Levi Weintraub <leviw@chromium.org>

Reviewed by Eric Seidel.

Switch RenderBoxModelObject::paintBorder to use IntRect instead of four ints
https://bugs.webkit.org/show_bug.cgi?id=60591

Switching RenderBoxModelObject::paintBorder to use IntRect instead of four ints representing a rect.

No new tests since there is no functionality change.

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::paintBoxDecorations):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintBoxDecorationsWithSize):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBorder):
* rendering/RenderBoxModelObject.h:
* rendering/RenderFieldset.cpp:
(WebCore::RenderFieldset::paintBoxDecorations):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::paintBoxDecorations):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::paintBoxDecorations):

2011-05-11 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r86255.
@@ -1127,7 +1127,7 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
// The simple case is where we either have no border image or we are the only box for this object. In those
// cases only a single call to draw is required.
if (!hasBorderImage || (!prevLineBox() && !nextLineBox()))
boxModelObject()->paintBorder(context, tx, ty, w, h, renderer()->style(), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
boxModelObject()->paintBorder(context, IntRect(tx, ty, w, h), renderer()->style(), BackgroundBleedNone, includeLogicalLeftEdge(), includeLogicalRightEdge());
else {
// We have a border image that spans multiple lines.
// We need to adjust tx and ty by the width of all previous lines.
@@ -1150,7 +1150,7 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)

GraphicsContextStateSaver stateSaver(*context);
context->clip(IntRect(tx, ty, w, h));
boxModelObject()->paintBorder(context, stripX, stripY, stripWidth, stripHeight, renderer()->style());
boxModelObject()->paintBorder(context, IntRect(stripX, stripY, stripWidth, stripHeight), renderer()->style());
}
}
}
@@ -873,7 +873,7 @@ void RenderBox::paintBoxDecorationsWithSize(PaintInfo& paintInfo, int tx, int ty

// The theme will tell us whether or not we should also paint the CSS border.
if ((!style()->hasAppearance() || (!themePainted && theme()->paintBorderOnly(this, paintInfo, IntRect(tx, ty, width, height)))) && style()->hasBorder())
paintBorder(paintInfo.context, tx, ty, width, height, style(), bleedAvoidance);
paintBorder(paintInfo.context, IntRect(tx, ty, width, height), style(), bleedAvoidance);

if (bleedAvoidance == BackgroundBleedUseTransparencyLayer)
paintInfo.context->endTransparencyLayer();
@@ -1346,11 +1346,11 @@ void RenderBoxModelObject::paintTranslucentBorderSides(GraphicsContext* graphics
}
}

void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h,
const RenderStyle* style, BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, const IntRect& rect, const RenderStyle* style,
BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
// border-image is not affected by border-radius.
if (paintNinePieceImage(graphicsContext, IntRect(tx, ty, w, h), style, style->borderImage()))
if (paintNinePieceImage(graphicsContext, rect, style, style->borderImage()))
return;

if (graphicsContext->paintingDisabled())
@@ -1359,9 +1359,8 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
BorderEdge edges[4];
getBorderEdgeInfo(edges, includeLogicalLeftEdge, includeLogicalRightEdge);

IntRect borderRect(tx, ty, w, h);
RoundedIntRect outerBorder = style->getRoundedBorderFor(borderRect, includeLogicalLeftEdge, includeLogicalRightEdge);
RoundedIntRect innerBorder = style->getRoundedInnerBorderFor(borderRect, includeLogicalLeftEdge, includeLogicalRightEdge);
RoundedIntRect outerBorder = style->getRoundedBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
RoundedIntRect innerBorder = style->getRoundedInnerBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);

const AffineTransform& currentCTM = graphicsContext->getCTM();
// FIXME: this isn't quite correct. We may want to antialias when scaled by a non-integral value, or when the translation is non-integral.
@@ -1587,12 +1586,12 @@ void RenderBoxModelObject::drawBoxSideFromPath(GraphicsContext* graphicsContext,
graphicsContext->drawRect(borderRect);
}
#else
void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, int ty, int w, int h,
const RenderStyle* style, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, const IntRect& rect, const RenderStyle* style,
BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
// FIXME: This old version of paintBorder should be removed when all ports implement
// GraphicsContext::clipConvexPolygon()!! This should happen soon.
if (paintNinePieceImage(graphicsContext, IntRect(tx, ty, w, h), style, style->borderImage()))
if (paintNinePieceImage(graphicsContext, rect, style, style->borderImage()))
return;

const Color& topColor = style->visitedDependentColor(CSSPropertyBorderTopColor);
@@ -1617,7 +1616,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
bool renderBottom = bottomStyle > BHIDDEN && !bottomTransparent && (horizontal || includeLogicalRightEdge);


RoundedIntRect border(tx, ty, w, h);
RoundedIntRect border(rect);

GraphicsContextStateSaver stateSaver(*graphicsContext, false);
if (style->hasBorderRadius()) {
@@ -1646,26 +1645,26 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
|| (topColor == rightColor && topTransparent == rightTransparent && topStyle >= OUTSET
&& (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET));

int x = tx;
int x2 = tx + w;
int x = rect.x();
int x2 = rect.maxX();
if (renderRadii) {
x += border.radii().topLeft().width();
x2 -= border.radii().topRight().width();
}

drawLineForBoxSide(graphicsContext, x, ty, x2, ty + style->borderTopWidth(), BSTop, topColor, topStyle,
drawLineForBoxSide(graphicsContext, x, rect.y(), x2, rect.y() + style->borderTopWidth(), BSTop, topColor, topStyle,
ignoreLeft ? 0 : style->borderLeftWidth(), ignoreRight ? 0 : style->borderRightWidth());

if (renderRadii) {
int leftY = ty;
int leftY = rect.y();

// We make the arc double thick and let the clip rect take care of clipping the extra off.
// We're doing this because it doesn't seem possible to match the curve of the clip exactly
// with the arc-drawing function.
thickness = style->borderTopWidth() * 2;

if (border.radii().topLeft().width()) {
int leftX = tx;
int leftX = rect.x();
// The inner clip clips inside the arc. This is especially important for 1px borders.
bool applyLeftInnerClip = (style->borderLeftWidth() < border.radii().topLeft().width())
&& (style->borderTopWidth() < border.radii().topLeft().height())
@@ -1685,7 +1684,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}

if (border.radii().topRight().width()) {
int rightX = tx + w - border.radii().topRight().width() * 2;
int rightX = rect.maxX() - border.radii().topRight().width() * 2;
bool applyRightInnerClip = (style->borderRightWidth() < border.radii().topRight().width())
&& (style->borderTopWidth() < border.radii().topRight().height())
&& (topStyle != DOUBLE || style->borderTopWidth() > 6);
@@ -1719,22 +1718,22 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
|| (bottomColor == rightColor && bottomTransparent == rightTransparent && bottomStyle >= OUTSET
&& (rightStyle == DOTTED || rightStyle == DASHED || rightStyle == SOLID || rightStyle == INSET));

int x = tx;
int x2 = tx + w;
int x = rect.x();
int x2 = rect.maxX();
if (renderRadii) {
x += border.radii().bottomLeft().width();
x2 -= border.radii().bottomRight().width();
}

drawLineForBoxSide(graphicsContext, x, ty + h - style->borderBottomWidth(), x2, ty + h, BSBottom, bottomColor, bottomStyle,
drawLineForBoxSide(graphicsContext, x, rect.maxY() - style->borderBottomWidth(), x2, rect.maxY(), BSBottom, bottomColor, bottomStyle,
ignoreLeft ? 0 : style->borderLeftWidth(), ignoreRight ? 0 : style->borderRightWidth());

if (renderRadii) {
thickness = style->borderBottomWidth() * 2;

if (border.radii().bottomLeft().width()) {
int leftX = tx;
int leftY = ty + h - border.radii().bottomLeft().height() * 2;
int leftX = rect.x();
int leftY = rect.maxY() - border.radii().bottomLeft().height() * 2;
bool applyLeftInnerClip = (style->borderLeftWidth() < border.radii().bottomLeft().width())
&& (style->borderBottomWidth() < border.radii().bottomLeft().height())
&& (bottomStyle != DOUBLE || style->borderBottomWidth() > 6);
@@ -1758,8 +1757,8 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}

if (border.radii().bottomRight().width()) {
int rightY = ty + h - border.radii().bottomRight().height() * 2;
int rightX = tx + w - border.radii().bottomRight().width() * 2;
int rightY = rect.maxY() - border.radii().bottomRight().height() * 2;
int rightX = rect.maxX() - border.radii().bottomRight().width() * 2;
bool applyRightInnerClip = (style->borderRightWidth() < border.radii().bottomRight().width())
&& (style->borderBottomWidth() < border.radii().bottomRight().height())
&& (bottomStyle != DOUBLE || style->borderBottomWidth() > 6);
@@ -1788,22 +1787,22 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
|| (bottomColor == leftColor && bottomTransparent == leftTransparent && leftStyle >= OUTSET
&& (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET));

int y = ty;
int y2 = ty + h;
int y = rect.y();
int y2 = rect.maxY();
if (renderRadii) {
y += border.radii().topLeft().height();
y2 -= border.radii().bottomLeft().height();
}

drawLineForBoxSide(graphicsContext, tx, y, tx + style->borderLeftWidth(), y2, BSLeft, leftColor, leftStyle,
drawLineForBoxSide(graphicsContext, rect.x(), y, rect.x() + style->borderLeftWidth(), y2, BSLeft, leftColor, leftStyle,
ignoreTop ? 0 : style->borderTopWidth(), ignoreBottom ? 0 : style->borderBottomWidth());

if (renderRadii && (!upperLeftBorderStylesMatch || !lowerLeftBorderStylesMatch)) {
int topX = tx;
int topX = rect.x();
thickness = style->borderLeftWidth() * 2;

if (!upperLeftBorderStylesMatch && border.radii().topLeft().width()) {
int topY = ty;
int topY = rect.y();
bool applyTopInnerClip = (style->borderLeftWidth() < border.radii().topLeft().width())
&& (style->borderTopWidth() < border.radii().topLeft().height())
&& (leftStyle != DOUBLE || style->borderLeftWidth() > 6);
@@ -1822,7 +1821,7 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}

if (!lowerLeftBorderStylesMatch && border.radii().bottomLeft().width()) {
int bottomY = ty + h - border.radii().bottomLeft().height() * 2;
int bottomY = rect.maxY() - border.radii().bottomLeft().height() * 2;
bool applyBottomInnerClip = (style->borderLeftWidth() < border.radii().bottomLeft().width())
&& (style->borderBottomWidth() < border.radii().bottomLeft().height())
&& (leftStyle != DOUBLE || style->borderLeftWidth() > 6);
@@ -1853,22 +1852,22 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
&& (rightStyle >= DOTTED || rightStyle == INSET)
&& (bottomStyle == DOTTED || bottomStyle == DASHED || bottomStyle == SOLID || bottomStyle == INSET));

int y = ty;
int y2 = ty + h;
int y = rect.y();
int y2 = rect.maxY();
if (renderRadii) {
y += border.radii().topRight().height();
y2 -= border.radii().bottomRight().height();
}

drawLineForBoxSide(graphicsContext, tx + w - style->borderRightWidth(), y, tx + w, y2, BSRight, rightColor, rightStyle,
drawLineForBoxSide(graphicsContext, rect.maxX() - style->borderRightWidth(), y, rect.maxX(), y2, BSRight, rightColor, rightStyle,
ignoreTop ? 0 : style->borderTopWidth(), ignoreBottom ? 0 : style->borderBottomWidth());

if (renderRadii && (!upperRightBorderStylesMatch || !lowerRightBorderStylesMatch)) {
thickness = style->borderRightWidth() * 2;

if (!upperRightBorderStylesMatch && border.radii().topRight().width()) {
int topX = tx + w - border.radii().topRight().width() * 2;
int topY = ty;
int topX = rect.maxX() - border.radii().topRight().width() * 2;
int topY = rect.y();
bool applyTopInnerClip = (style->borderRightWidth() < border.radii().topRight().width())
&& (style->borderTopWidth() < border.radii().topRight().height())
&& (rightStyle != DOUBLE || style->borderRightWidth() > 6);
@@ -1887,8 +1886,8 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx,
}

if (!lowerRightBorderStylesMatch && border.radii().bottomRight().width()) {
int bottomX = tx + w - border.radii().bottomRight().width() * 2;
int bottomY = ty + h - border.radii().bottomRight().height() * 2;
int bottomX = rect.maxX() - border.radii().bottomRight().width() * 2;
int bottomY = rect.maxY() - border.radii().bottomRight().height() * 2;
bool applyBottomInnerClip = (style->borderRightWidth() < border.radii().bottomRight().width())
&& (style->borderBottomWidth() < border.radii().bottomRight().height())
&& (rightStyle != DOUBLE || style->borderRightWidth() > 6);
@@ -118,7 +118,7 @@ class RenderBoxModelObject : public RenderObject {

virtual void childBecameNonInline(RenderObject* /*child*/) { }

void paintBorder(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
void paintBorder(GraphicsContext*, const IntRect&, const RenderStyle*, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
bool paintNinePieceImage(GraphicsContext*, const IntRect&, const RenderStyle*, const NinePieceImage&, CompositeOperator = CompositeSourceOver);
void paintBoxShadow(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, BackgroundBleedAvoidance, InlineFlowBox* = 0, int inlineBoxWidth = 0, int inlineBoxHeight = 0, CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);
@@ -167,7 +167,7 @@ void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
graphicsContext->clipOut(IntRect(clipLeft, ty + legend->y(), clipWidth, legend->height()));
}

paintBorder(paintInfo.context, tx, ty, w, h, style());
paintBorder(paintInfo.context, IntRect(tx, ty, w, h), style());
}

void RenderFieldset::paintMask(PaintInfo& paintInfo, int tx, int ty)
@@ -570,7 +570,7 @@ void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
paintBoxShadow(paintInfo.context, rect.x(), rect.y(), rect.width(), rect.height(), style(), Inset);

if (style()->hasBorder() && !collapseBorders())
paintBorder(paintInfo.context, rect.x(), rect.y(), rect.width(), rect.height(), style());
paintBorder(paintInfo.context, rect, style());
}

void RenderTable::paintMask(PaintInfo& paintInfo, int tx, int ty)
@@ -1020,7 +1020,7 @@ void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
if (!style()->hasBorder() || tableElt->collapseBorders())
return;

paintBorder(paintInfo.context, tx, ty, w, h, style());
paintBorder(paintInfo.context, IntRect(tx, ty, w, h), style());
}

void RenderTableCell::paintMask(PaintInfo& paintInfo, int tx, int ty)

0 comments on commit 485a827

Please sign in to comment.