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

        Switch paintFillLayer and its progeny to use IntRect instead of four ints
        https://bugs.webkit.org/show_bug.cgi?id=60596

        Changing integers passed into paintFillLayer and other derivatives to IntRects
        and IntSizes that reflect their function.

        No new tests since this is just refactoring.

        * rendering/InlineFlowBox.cpp:
        (WebCore::InlineFlowBox::paintFillLayers):
        (WebCore::InlineFlowBox::paintFillLayer):
        (WebCore::InlineFlowBox::paintBoxDecorations):
        (WebCore::InlineFlowBox::paintMask):
        * rendering/InlineFlowBox.h:
        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::paintRootBoxFillLayers):
        (WebCore::RenderBox::paintBoxDecorationsWithSize):
        (WebCore::RenderBox::paintMaskImages):
        (WebCore::RenderBox::paintFillLayers):
        (WebCore::RenderBox::paintFillLayer):
        * rendering/RenderBox.h:
        * rendering/RenderBoxModelObject.cpp:
        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
        * rendering/RenderBoxModelObject.h:
        * rendering/RenderFieldset.cpp:
        (WebCore::RenderFieldset::paintBoxDecorations):
        * rendering/RenderTable.cpp:
        (WebCore::RenderTable::paintBoxDecorations):
        * rendering/RenderTableCell.cpp:
        (WebCore::RenderTableCell::paintBackgroundsBehindCell):

Canonical link: https://commits.webkit.org/75960@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@86303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
leviw committed May 12, 2011
1 parent b5d1b2d commit c872593778f83dece4cd172d61e578d72338d6aa
Showing 10 changed files with 95 additions and 62 deletions.
@@ -1,3 +1,38 @@
2011-05-11 Levi Weintraub <leviw@chromium.org>

Reviewed by Eric Seidel.

Switch paintFillLayer and its progeny to use IntRect instead of four ints
https://bugs.webkit.org/show_bug.cgi?id=60596

Changing integers passed into paintFillLayer and other derivatives to IntRects
and IntSizes that reflect their function.

No new tests since this is just refactoring.

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::paintFillLayers):
(WebCore::InlineFlowBox::paintFillLayer):
(WebCore::InlineFlowBox::paintBoxDecorations):
(WebCore::InlineFlowBox::paintMask):
* rendering/InlineFlowBox.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintRootBoxFillLayers):
(WebCore::RenderBox::paintBoxDecorationsWithSize):
(WebCore::RenderBox::paintMaskImages):
(WebCore::RenderBox::paintFillLayers):
(WebCore::RenderBox::paintFillLayer):
* rendering/RenderBox.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* rendering/RenderBoxModelObject.h:
* rendering/RenderFieldset.cpp:
(WebCore::RenderFieldset::paintBoxDecorations):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::paintBoxDecorations):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::paintBackgroundsBehindCell):

2011-05-11 Nat Duca <nduca@chromium.org>

Reviewed by James Robinson.
@@ -1016,20 +1016,20 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, int tx, int ty, int lineTop, int
}
}

void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int _tx, int _ty, int w, int h, CompositeOperator op)
void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const IntRect& rect, CompositeOperator op)
{
if (!fillLayer)
return;
paintFillLayers(paintInfo, c, fillLayer->next(), _tx, _ty, w, h, op);
paintFillLayer(paintInfo, c, fillLayer, _tx, _ty, w, h, op);
paintFillLayers(paintInfo, c, fillLayer->next(), rect, op);
paintFillLayer(paintInfo, c, fillLayer, rect, op);
}

void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int tx, int ty, int w, int h, CompositeOperator op)
void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const IntRect& rect, CompositeOperator op)
{
StyleImage* img = fillLayer->image();
bool hasFillImage = img && img->canRender(renderer()->style()->effectiveZoom());
if ((!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent())
boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, tx, ty, w, h, BackgroundBleedNone, this, w, h, op);
boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect, BackgroundBleedNone, this, rect.size(), op);
else {
// We have a fill image that spans multiple lines.
// We need to adjust tx and ty by the width of all previous lines.
@@ -1052,14 +1052,14 @@ void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c
for (InlineFlowBox* curr = this; curr; curr = curr->prevLineBox())
totalLogicalWidth += curr->logicalWidth();
}
int stripX = tx - (isHorizontal() ? logicalOffsetOnLine : 0);
int stripY = ty - (isHorizontal() ? 0 : logicalOffsetOnLine);
int stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : 0);
int stripY = rect.y() - (isHorizontal() ? 0 : logicalOffsetOnLine);
int stripWidth = isHorizontal() ? totalLogicalWidth : width();
int stripHeight = isHorizontal() ? height() : totalLogicalWidth;

GraphicsContextStateSaver stateSaver(*paintInfo.context);
paintInfo.context->clip(IntRect(tx, ty, width(), height()));
boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, stripX, stripY, stripWidth, stripHeight, BackgroundBleedNone, this, w, h, op);
paintInfo.context->clip(IntRect(rect.x(), rect.y(), width(), height()));
boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, IntRect(stripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, this, rect.size(), op);
}
}

@@ -1113,7 +1113,7 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
paintBoxShadow(context, styleToUse, Normal, tx, ty, w, h);

Color c = styleToUse->visitedDependentColor(CSSPropertyBackgroundColor);
paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), tx, ty, w, h);
paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), IntRect(tx, ty, w, h));
paintBoxShadow(context, styleToUse, Inset, tx, ty, w, h);

// :first-line cannot be used to put borders on a line. Always paint borders with our
@@ -1204,7 +1204,7 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, int tx, int ty)
}
}

paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), tx, ty, w, h, compositeOp);
paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), IntRect(tx, ty, w, h), compositeOp);

bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer()->style()->effectiveZoom());
if (!hasBoxImage || !maskBoxImage->isLoaded())
@@ -105,8 +105,8 @@ class InlineFlowBox : public InlineBox {

virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);
virtual void paintMask(PaintInfo&, int tx, int ty);
void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver);
void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver);
void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, CompositeOperator = CompositeSourceOver);
void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, CompositeOperator = CompositeSourceOver);
void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, int tx, int ty, int w, int h);
virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, int lineTop, int lineBottom);
@@ -799,7 +799,7 @@ void RenderBox::paintRootBoxFillLayers(const PaintInfo& paintInfo)

// The background of the box generated by the root element covers the entire canvas, so just use
// the RenderView's docTop/Left/Width/Height accessors.
paintFillLayers(paintInfo, bgColor, bgLayer, view()->docLeft(), view()->docTop(), view()->docWidth(), view()->docHeight(), BackgroundBleedNone, CompositeSourceOver, bodyObject);
paintFillLayers(paintInfo, bgColor, bgLayer, view()->documentRect(), BackgroundBleedNone, CompositeSourceOver, bodyObject);
}

void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
@@ -834,6 +834,7 @@ BackgroundBleedAvoidance RenderBox::determineBackgroundBleedAvoidance(GraphicsCo

void RenderBox::paintBoxDecorationsWithSize(PaintInfo& paintInfo, int tx, int ty, int width, int height)
{
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);
@@ -849,30 +850,30 @@ void RenderBox::paintBoxDecorationsWithSize(PaintInfo& paintInfo, int tx, int ty
// To avoid the background color bleeding out behind the border, we'll render background and border
// into a transparency layer, and then clip that in one go (which requires setting up the clip before
// beginning the layer).
RoundedIntRect border = style()->getRoundedBorderFor(IntRect(tx, ty, width, height));
RoundedIntRect border = style()->getRoundedBorderFor(paintRect);
stateSaver.save();
paintInfo.context->addRoundedRectClip(border);
paintInfo.context->beginTransparencyLayer(1);
}

// If we have a native theme appearance, paint that before painting our background.
// The theme will tell us whether or not we should also paint the CSS background.
bool themePainted = style()->hasAppearance() && !theme()->paint(this, paintInfo, IntRect(tx, ty, width, height));
bool themePainted = style()->hasAppearance() && !theme()->paint(this, paintInfo, paintRect);
if (!themePainted) {
if (isRoot())
paintRootBoxFillLayers(paintInfo);
else if (!isBody() || document()->documentElement()->renderer()->hasBackground()) {
// The <body> only paints its background if the root element has defined a background
// independent of the body.
paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), tx, ty, width, height, bleedAvoidance);
paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), paintRect, bleedAvoidance);
}
if (style()->hasAppearance())
theme()->paintDecorations(this, paintInfo, IntRect(tx, ty, width, height));
theme()->paintDecorations(this, paintInfo, paintRect);
}
paintBoxShadow(paintInfo.context, tx, ty, width, 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, IntRect(tx, ty, width, height)))) && style()->hasBorder())
if ((!style()->hasAppearance() || (!themePainted && theme()->paintBorderOnly(this, paintInfo, paintRect))) && style()->hasBorder())
paintBorder(paintInfo.context, IntRect(tx, ty, width, height), style(), bleedAvoidance);

if (bleedAvoidance == BackgroundBleedUseTransparencyLayer)
@@ -952,8 +953,9 @@ void RenderBox::paintMaskImages(const PaintInfo& paintInfo, int tx, int ty, int
}

if (allMaskImagesLoaded) {
paintFillLayers(paintInfo, Color(), style()->maskLayers(), tx, ty, w, h, BackgroundBleedNone, compositeOp);
paintNinePieceImage(paintInfo.context, IntRect(tx, ty, w, h), style(), style()->maskBoxImage(), compositeOp);
IntRect paintRect = IntRect(tx, ty, w, h);
paintFillLayers(paintInfo, Color(), style()->maskLayers(), paintRect, BackgroundBleedNone, compositeOp);
paintNinePieceImage(paintInfo.context, paintRect, style(), style()->maskBoxImage(), compositeOp);
}

if (pushTransparencyLayer)
@@ -979,20 +981,20 @@ IntRect RenderBox::maskClipRect()
return result;
}

void RenderBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int tx, int ty, int width, int height,
void RenderBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const IntRect& rect,
BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderObject* backgroundObject)
{
if (!fillLayer)
return;

paintFillLayers(paintInfo, c, fillLayer->next(), tx, ty, width, height, bleedAvoidance, op, backgroundObject);
paintFillLayer(paintInfo, c, fillLayer, tx, ty, width, height, bleedAvoidance, op, backgroundObject);
paintFillLayers(paintInfo, c, fillLayer->next(), rect, bleedAvoidance, op, backgroundObject);
paintFillLayer(paintInfo, c, fillLayer, rect, bleedAvoidance, op, backgroundObject);
}

void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int tx, int ty, int width, int height,
void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const IntRect& rect,
BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderObject* backgroundObject)
{
paintFillLayerExtended(paintInfo, c, fillLayer, tx, ty, width, height, bleedAvoidance, 0, 0, 0, op, backgroundObject);
paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, 0, IntSize(), op, backgroundObject);
}

#if USE(ACCELERATED_COMPOSITING)
@@ -405,8 +405,8 @@ class RenderBox : public RenderBoxModelObject {
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
virtual void updateBoxModelInfoFromStyle();

void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, BackgroundBleedAvoidance, CompositeOperator, RenderObject* backgroundObject);
void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, BackgroundBleedAvoidance = BackgroundBleedNone, CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);
void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, BackgroundBleedAvoidance, CompositeOperator, RenderObject* backgroundObject);
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);

0 comments on commit c872593

Please sign in to comment.