Changeset 86303 in webkit
- Timestamp:
- May 11, 2011 8:17:57 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86301 r86303 1 2011-05-11 Levi Weintraub <leviw@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Switch paintFillLayer and its progeny to use IntRect instead of four ints 6 https://bugs.webkit.org/show_bug.cgi?id=60596 7 8 Changing integers passed into paintFillLayer and other derivatives to IntRects 9 and IntSizes that reflect their function. 10 11 No new tests since this is just refactoring. 12 13 * rendering/InlineFlowBox.cpp: 14 (WebCore::InlineFlowBox::paintFillLayers): 15 (WebCore::InlineFlowBox::paintFillLayer): 16 (WebCore::InlineFlowBox::paintBoxDecorations): 17 (WebCore::InlineFlowBox::paintMask): 18 * rendering/InlineFlowBox.h: 19 * rendering/RenderBox.cpp: 20 (WebCore::RenderBox::paintRootBoxFillLayers): 21 (WebCore::RenderBox::paintBoxDecorationsWithSize): 22 (WebCore::RenderBox::paintMaskImages): 23 (WebCore::RenderBox::paintFillLayers): 24 (WebCore::RenderBox::paintFillLayer): 25 * rendering/RenderBox.h: 26 * rendering/RenderBoxModelObject.cpp: 27 (WebCore::RenderBoxModelObject::paintFillLayerExtended): 28 * rendering/RenderBoxModelObject.h: 29 * rendering/RenderFieldset.cpp: 30 (WebCore::RenderFieldset::paintBoxDecorations): 31 * rendering/RenderTable.cpp: 32 (WebCore::RenderTable::paintBoxDecorations): 33 * rendering/RenderTableCell.cpp: 34 (WebCore::RenderTableCell::paintBackgroundsBehindCell): 35 1 36 2011-05-11 Nat Duca <nduca@chromium.org> 2 37 -
trunk/Source/WebCore/rendering/InlineFlowBox.cpp
r86272 r86303 1017 1017 } 1018 1018 1019 void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int _tx, int _ty, int w, int h, CompositeOperator op)1019 void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const IntRect& rect, CompositeOperator op) 1020 1020 { 1021 1021 if (!fillLayer) 1022 1022 return; 1023 paintFillLayers(paintInfo, c, fillLayer->next(), _tx, _ty, w, h, op);1024 paintFillLayer(paintInfo, c, fillLayer, _tx, _ty, w, h, op);1025 } 1026 1027 void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int tx, int ty, int w, int h, CompositeOperator op)1023 paintFillLayers(paintInfo, c, fillLayer->next(), rect, op); 1024 paintFillLayer(paintInfo, c, fillLayer, rect, op); 1025 } 1026 1027 void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const IntRect& rect, CompositeOperator op) 1028 1028 { 1029 1029 StyleImage* img = fillLayer->image(); 1030 1030 bool hasFillImage = img && img->canRender(renderer()->style()->effectiveZoom()); 1031 1031 if ((!hasFillImage && !renderer()->style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent()) 1032 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, tx, ty, w, h, BackgroundBleedNone, this, w, h, op);1032 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, rect, BackgroundBleedNone, this, rect.size(), op); 1033 1033 else { 1034 1034 // We have a fill image that spans multiple lines. … … 1053 1053 totalLogicalWidth += curr->logicalWidth(); 1054 1054 } 1055 int stripX = tx- (isHorizontal() ? logicalOffsetOnLine : 0);1056 int stripY = ty- (isHorizontal() ? 0 : logicalOffsetOnLine);1055 int stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : 0); 1056 int stripY = rect.y() - (isHorizontal() ? 0 : logicalOffsetOnLine); 1057 1057 int stripWidth = isHorizontal() ? totalLogicalWidth : width(); 1058 1058 int stripHeight = isHorizontal() ? height() : totalLogicalWidth; 1059 1059 1060 1060 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1061 paintInfo.context->clip(IntRect( tx, ty, width(), height()));1062 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, stripX, stripY, stripWidth, stripHeight, BackgroundBleedNone, this, w, h, op);1061 paintInfo.context->clip(IntRect(rect.x(), rect.y(), width(), height())); 1062 boxModelObject()->paintFillLayerExtended(paintInfo, c, fillLayer, IntRect(stripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, this, rect.size(), op); 1063 1063 } 1064 1064 } … … 1114 1114 1115 1115 Color c = styleToUse->visitedDependentColor(CSSPropertyBackgroundColor); 1116 paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), tx, ty, w, h);1116 paintFillLayers(paintInfo, c, styleToUse->backgroundLayers(), IntRect(tx, ty, w, h)); 1117 1117 paintBoxShadow(context, styleToUse, Inset, tx, ty, w, h); 1118 1118 … … 1205 1205 } 1206 1206 1207 paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), tx, ty, w, h, compositeOp);1207 paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), IntRect(tx, ty, w, h), compositeOp); 1208 1208 1209 1209 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer()->style()->effectiveZoom()); -
trunk/Source/WebCore/rendering/InlineFlowBox.h
r85512 r86303 106 106 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); 107 107 virtual void paintMask(PaintInfo&, int tx, int ty); 108 void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver);109 void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver);108 void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, CompositeOperator = CompositeSourceOver); 109 void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, CompositeOperator = CompositeSourceOver); 110 110 void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, int tx, int ty, int w, int h); 111 111 virtual void paint(PaintInfo&, int tx, int ty, int lineTop, int lineBottom); -
trunk/Source/WebCore/rendering/RenderBox.cpp
r86272 r86303 800 800 // The background of the box generated by the root element covers the entire canvas, so just use 801 801 // the RenderView's docTop/Left/Width/Height accessors. 802 paintFillLayers(paintInfo, bgColor, bgLayer, view()->doc Left(), view()->docTop(), view()->docWidth(), view()->docHeight(), BackgroundBleedNone, CompositeSourceOver, bodyObject);802 paintFillLayers(paintInfo, bgColor, bgLayer, view()->documentRect(), BackgroundBleedNone, CompositeSourceOver, bodyObject); 803 803 } 804 804 … … 835 835 void RenderBox::paintBoxDecorationsWithSize(PaintInfo& paintInfo, int tx, int ty, int width, int height) 836 836 { 837 IntRect paintRect = IntRect(tx, ty, width, height); 837 838 // border-fit can adjust where we paint our border and background. If set, we snugly fit our line box descendants. (The iChat 838 839 // balloon layout is an example of this). … … 850 851 // into a transparency layer, and then clip that in one go (which requires setting up the clip before 851 852 // beginning the layer). 852 RoundedIntRect border = style()->getRoundedBorderFor( IntRect(tx, ty, width, height));853 RoundedIntRect border = style()->getRoundedBorderFor(paintRect); 853 854 stateSaver.save(); 854 855 paintInfo.context->addRoundedRectClip(border); … … 858 859 // If we have a native theme appearance, paint that before painting our background. 859 860 // The theme will tell us whether or not we should also paint the CSS background. 860 bool themePainted = style()->hasAppearance() && !theme()->paint(this, paintInfo, IntRect(tx, ty, width, height));861 bool themePainted = style()->hasAppearance() && !theme()->paint(this, paintInfo, paintRect); 861 862 if (!themePainted) { 862 863 if (isRoot()) … … 865 866 // The <body> only paints its background if the root element has defined a background 866 867 // independent of the body. 867 paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), tx, ty, width, height, bleedAvoidance);868 paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), paintRect, bleedAvoidance); 868 869 } 869 870 if (style()->hasAppearance()) 870 theme()->paintDecorations(this, paintInfo, IntRect(tx, ty, width, height));871 theme()->paintDecorations(this, paintInfo, paintRect); 871 872 } 872 873 paintBoxShadow(paintInfo.context, tx, ty, width, height, style(), Inset); 873 874 874 875 // The theme will tell us whether or not we should also paint the CSS border. 875 if ((!style()->hasAppearance() || (!themePainted && theme()->paintBorderOnly(this, paintInfo, IntRect(tx, ty, width, height)))) && style()->hasBorder())876 if ((!style()->hasAppearance() || (!themePainted && theme()->paintBorderOnly(this, paintInfo, paintRect))) && style()->hasBorder()) 876 877 paintBorder(paintInfo.context, IntRect(tx, ty, width, height), style(), bleedAvoidance); 877 878 … … 953 954 954 955 if (allMaskImagesLoaded) { 955 paintFillLayers(paintInfo, Color(), style()->maskLayers(), tx, ty, w, h, BackgroundBleedNone, compositeOp); 956 paintNinePieceImage(paintInfo.context, IntRect(tx, ty, w, h), style(), style()->maskBoxImage(), compositeOp); 956 IntRect paintRect = IntRect(tx, ty, w, h); 957 paintFillLayers(paintInfo, Color(), style()->maskLayers(), paintRect, BackgroundBleedNone, compositeOp); 958 paintNinePieceImage(paintInfo.context, paintRect, style(), style()->maskBoxImage(), compositeOp); 957 959 } 958 960 … … 980 982 } 981 983 982 void RenderBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int tx, int ty, int width, int height,984 void RenderBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const IntRect& rect, 983 985 BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderObject* backgroundObject) 984 986 { … … 986 988 return; 987 989 988 paintFillLayers(paintInfo, c, fillLayer->next(), tx, ty, width, height, bleedAvoidance, op, backgroundObject);989 paintFillLayer(paintInfo, c, fillLayer, tx, ty, width, height, bleedAvoidance, op, backgroundObject);990 } 991 992 void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int tx, int ty, int width, int height,990 paintFillLayers(paintInfo, c, fillLayer->next(), rect, bleedAvoidance, op, backgroundObject); 991 paintFillLayer(paintInfo, c, fillLayer, rect, bleedAvoidance, op, backgroundObject); 992 } 993 994 void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, const IntRect& rect, 993 995 BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderObject* backgroundObject) 994 996 { 995 paintFillLayerExtended(paintInfo, c, fillLayer, tx, ty, width, height, bleedAvoidance, 0, 0, 0, op, backgroundObject);997 paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, 0, IntSize(), op, backgroundObject); 996 998 } 997 999 -
trunk/Source/WebCore/rendering/RenderBox.h
r86197 r86303 406 406 virtual void updateBoxModelInfoFromStyle(); 407 407 408 void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, BackgroundBleedAvoidance, CompositeOperator, RenderObject* backgroundObject);409 void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int width, int height, BackgroundBleedAvoidance = BackgroundBleedNone, CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0);408 void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, BackgroundBleedAvoidance, CompositeOperator, RenderObject* backgroundObject); 409 void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, BackgroundBleedAvoidance = BackgroundBleedNone, CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0); 410 410 411 411 void paintBoxDecorationsWithSize(PaintInfo&, int tx, int ty, int width, int height); -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r86272 r86303 586 586 } 587 587 588 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, const Color& color, const FillLayer* bgLayer, int tx, int ty, int w, int h,589 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, int inlineBoxWidth, int inlineBoxHeight, CompositeOperator op, RenderObject* backgroundObject)588 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, const Color& color, const FillLayer* bgLayer, const IntRect& rect, 589 BackgroundBleedAvoidance bleedAvoidance, InlineFlowBox* box, const IntSize& boxSize, CompositeOperator op, RenderObject* backgroundObject) 590 590 { 591 591 GraphicsContext* context = paintInfo.context; 592 if (context->paintingDisabled()) 593 return; 594 595 IntRect borderRect(tx, ty, w, h); 596 if (borderRect.isEmpty()) 592 if (context->paintingDisabled() || rect.isEmpty()) 597 593 return; 598 594 … … 632 628 633 629 if (hasRoundedBorder && bleedAvoidance != BackgroundBleedUseTransparencyLayer) { 634 RoundedIntRect border = getBackgroundRoundedRect(backgroundRectAdjustedForBleedAvoidance(context, borderRect, bleedAvoidance), box, inlineBoxWidth, inlineBoxHeight, includeLeftEdge, includeRightEdge);630 RoundedIntRect border = getBackgroundRoundedRect(backgroundRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance), box, boxSize.width(), boxSize.height(), includeLeftEdge, includeRightEdge); 635 631 context->fillRoundedRect(border, bgColor, style()->colorSpace()); 636 632 } else 637 context->fillRect( borderRect, bgColor, style()->colorSpace());633 context->fillRect(rect, bgColor, style()->colorSpace()); 638 634 639 635 return; … … 643 639 GraphicsContextStateSaver clipToBorderStateSaver(*context, clipToBorderRadius); 644 640 if (clipToBorderRadius) { 645 RoundedIntRect border = getBackgroundRoundedRect(backgroundRectAdjustedForBleedAvoidance(context, borderRect, bleedAvoidance), box, inlineBoxWidth, inlineBoxHeight, includeLeftEdge, includeRightEdge);641 RoundedIntRect border = getBackgroundRoundedRect(backgroundRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance), box, boxSize.width(), boxSize.height(), includeLeftEdge, includeRightEdge); 646 642 context->addRoundedRectClip(border); 647 643 } … … 653 649 654 650 GraphicsContextStateSaver clipWithScrollingStateSaver(*context, clippedWithLocalScrolling); 651 IntRect scrolledPaintRect = rect; 655 652 if (clippedWithLocalScrolling) { 656 653 // Clip to the overflow area. 657 context->clip(toRenderBox(this)->overflowClipRect( tx, ty));654 context->clip(toRenderBox(this)->overflowClipRect(rect.x(), rect.y())); 658 655 659 // Now adjust our tx, ty, w, hto reflect a scrolled content box with borders at the ends.656 // Adjust the paint rect to reflect a scrolled content box with borders at the ends. 660 657 IntSize offset = layer()->scrolledContentOffset(); 661 tx -= offset.width(); 662 ty -= offset.height(); 663 w = bLeft + layer()->scrollWidth() + bRight; 664 h = borderTop() + layer()->scrollHeight() + borderBottom(); 658 scrolledPaintRect.move(-offset); 659 scrolledPaintRect.setWidth(bLeft + layer()->scrollWidth() + bRight); 660 scrolledPaintRect.setHeight(borderTop() + layer()->scrollHeight() + borderBottom()); 665 661 } 666 662 … … 669 665 // Clip to the padding or content boxes as necessary. 670 666 bool includePadding = bgLayer->clip() == ContentFillBox; 671 int x = tx + bLeft + (includePadding ? pLeft : 0);672 int y = ty + borderTop() + (includePadding ? paddingTop() : 0);673 int width = w - bLeft - bRight - (includePadding ? pLeft + pRight : 0);674 int height = h - borderTop() - borderBottom() - (includePadding ? paddingTop() + paddingBottom() : 0);667 IntRect clipRect = IntRect(scrolledPaintRect.x() + bLeft + (includePadding ? pLeft : 0), 668 scrolledPaintRect.y() + borderTop() + (includePadding ? paddingTop() : 0), 669 scrolledPaintRect.width() - bLeft - bRight - (includePadding ? pLeft + pRight : 0), 670 scrolledPaintRect.height() - borderTop() - borderBottom() - (includePadding ? paddingTop() + paddingBottom() : 0)); 675 671 backgroundClipStateSaver.save(); 676 context->clip( IntRect(x, y, width, height));672 context->clip(clipRect); 677 673 } else if (bgLayer->clip() == TextFillBox) { 678 674 // We have to draw our text into a mask that can then be used to clip background drawing. 679 675 // First figure out how big the mask has to be. It should be no bigger than what we need 680 676 // to actually render, so we should intersect the dirty rect with the border box of the background. 681 IntRect maskRect (tx, ty, w, h);677 IntRect maskRect = rect; 682 678 maskRect.intersect(paintInfo.rect); 683 679 … … 695 691 if (box) { 696 692 RootInlineBox* root = box->root(); 697 box->paint(info, tx - box->x(), ty- box->y(), root->lineTop(), root->lineBottom());693 box->paint(info, scrolledPaintRect.x() - box->x(), scrolledPaintRect.y() - box->y(), root->lineTop(), root->lineBottom()); 698 694 } else { 699 695 int x = isBox() ? toRenderBox(this)->x() : 0; 700 696 int y = isBox() ? toRenderBox(this)->y() : 0; 701 paint(info, tx - x, ty- y);697 paint(info, scrolledPaintRect.x() - x, scrolledPaintRect.y() - y); 702 698 } 703 699 … … 740 736 // Paint the color first underneath all images. 741 737 if (!bgLayer->next()) { 742 IntRect rect(tx, ty, w, h);743 rect.intersect(paintInfo.rect);738 IntRect backgroundRect(scrolledPaintRect); 739 backgroundRect.intersect(paintInfo.rect); 744 740 // If we have an alpha and we are painting the root element, go ahead and blend with the base background color. 745 741 if (isOpaqueRoot) { … … 748 744 CompositeOperator previousOperator = context->compositeOperation(); 749 745 context->setCompositeOperation(CompositeCopy); 750 context->fillRect( rect, baseColor, style()->colorSpace());746 context->fillRect(backgroundRect, baseColor, style()->colorSpace()); 751 747 context->setCompositeOperation(previousOperator); 752 748 } else 753 context->clearRect( rect);749 context->clearRect(backgroundRect); 754 750 } 755 751 756 752 if (bgColor.isValid() && bgColor.alpha() > 0) 757 context->fillRect( rect, bgColor, style()->colorSpace());753 context->fillRect(backgroundRect, bgColor, style()->colorSpace()); 758 754 } 759 755 … … 764 760 IntSize tileSize; 765 761 766 calculateBackgroundImageGeometry(bgLayer, tx, ty, w, h, destRect, phase, tileSize);762 calculateBackgroundImageGeometry(bgLayer, scrolledPaintRect.x(), scrolledPaintRect.y(), scrolledPaintRect.width(), scrolledPaintRect.height(), destRect, phase, tileSize); 767 763 IntPoint destOrigin = destRect.location(); 768 764 destRect.intersect(paintInfo.rect); -
trunk/Source/WebCore/rendering/RenderBoxModelObject.h
r86272 r86303 122 122 bool paintNinePieceImage(GraphicsContext*, const IntRect&, const RenderStyle*, const NinePieceImage&, CompositeOperator = CompositeSourceOver); 123 123 void paintBoxShadow(GraphicsContext*, int tx, int ty, int w, int h, const RenderStyle*, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true); 124 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);124 void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, BackgroundBleedAvoidance, InlineFlowBox* = 0, const IntSize& = IntSize(), CompositeOperator = CompositeSourceOver, RenderObject* backgroundObject = 0); 125 125 126 126 // Overridden by subclasses to determine line height and baseline position. -
trunk/Source/WebCore/rendering/RenderFieldset.cpp
r86272 r86303 145 145 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Normal); 146 146 147 paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), tx, ty, w, h);147 paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), IntRect(tx, ty, w, h)); 148 148 paintBoxShadow(paintInfo.context, tx, ty, w, h, style(), Inset); 149 149 -
trunk/Source/WebCore/rendering/RenderTable.cpp
r86272 r86303 566 566 // The <body> only paints its background if the root element has defined a background 567 567 // independent of the body. 568 paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), rect .x(), rect.y(), rect.width(), rect.height());568 paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), rect); 569 569 570 570 paintBoxShadow(paintInfo.context, rect.x(), rect.y(), rect.width(), rect.height(), style(), Inset); -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r86272 r86303 995 995 paintInfo.context->clip(clipRect); 996 996 } 997 paintFillLayers(paintInfo, c, bgLayer, tx, ty, w, h, BackgroundBleedNone, CompositeSourceOver, backgroundObject);997 paintFillLayers(paintInfo, c, bgLayer, IntRect(tx, ty, w, h), BackgroundBleedNone, CompositeSourceOver, backgroundObject); 998 998 } 999 999 }
Note: See TracChangeset
for help on using the changeset viewer.