Changeset 86377 in webkit
- Timestamp:
- May 12, 2011 2:05:13 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86375 r86377 1 2011-05-12 Levi Weintraub <leviw@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Switch paintMask and paintMaskImages off of ints 6 https://bugs.webkit.org/show_bug.cgi?id=60578 7 8 Primarily switching paintMask and paintMaskImages to use IntSize and IntRect respectively. 9 In the process of that: 10 - added an "expand" function to IntRect that allows you to add an IntSize or pair of 11 integers to the size portion of an IntRect. 12 - changed borderFitAdjust to take an IntRect. It modifies only the x and width attributes. 13 14 No new tests since this refactoring. 15 16 * platform/graphics/IntRect.h: 17 (WebCore::IntRect::expand): Added for convenience. 18 * rendering/RenderBlock.cpp: 19 (WebCore::RenderBlock::paintObject): 20 (WebCore::RenderBlock::borderFitAdjust): 21 * rendering/RenderBlock.h: 22 * rendering/RenderBox.cpp: 23 (WebCore::RenderBox::paintBoxDecorationsWithSize): 24 (WebCore::RenderBox::paintMask): 25 (WebCore::RenderBox::paintMaskImages): 26 * rendering/RenderBox.h: 27 (WebCore::RenderBox::borderFitAdjust): 28 * rendering/RenderFieldset.cpp: 29 (WebCore::RenderFieldset::paintMask): 30 * rendering/RenderFieldset.h: 31 * rendering/RenderReplaced.cpp: 32 (WebCore::RenderReplaced::paint): 33 * rendering/RenderReplica.cpp: 34 (WebCore::RenderReplica::paint): 35 * rendering/RenderTable.cpp: 36 (WebCore::RenderTable::paintObject): 37 (WebCore::RenderTable::paintMask): 38 * rendering/RenderTable.h: 39 * rendering/RenderTableCell.cpp: 40 (WebCore::RenderTableCell::paintMask): 41 * rendering/RenderTableCell.h: 42 * rendering/RenderWidget.cpp: 43 (WebCore::RenderWidget::paint): 44 1 45 2011-05-12 Patrick Gansterer <paroga@webkit.org> 2 46 -
trunk/Source/WebCore/platform/graphics/IntRect.h
r84273 r86377 108 108 IntPoint center() const { return IntPoint(x() + width() / 2, y() + height() / 2); } 109 109 110 void move(const IntSize& s ) { m_location += s; }110 void move(const IntSize& size) { m_location += size; } 111 111 void move(int dx, int dy) { m_location.move(dx, dy); } 112 112 113 void expand(const IntSize& size) { m_location += size; } 114 void expand(int dw, int dh) { m_size.expand(dw, dh); } 115 113 116 void shiftXEdgeTo(int edge) 114 117 { -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r86160 r86377 2463 2463 2464 2464 if (paintPhase == PaintPhaseMask && style()->visibility() == VISIBLE) { 2465 paintMask(paintInfo, tx, ty);2465 paintMask(paintInfo, IntSize(tx, ty)); 2466 2466 return; 2467 2467 } … … 5596 5596 } 5597 5597 5598 void RenderBlock::borderFitAdjust( int& x, int& w) const5598 void RenderBlock::borderFitAdjust(IntRect& rect) const 5599 5599 { 5600 5600 if (style()->borderFit() == BorderFitBorder) … … 5604 5604 int left = INT_MAX; 5605 5605 int right = INT_MIN; 5606 int oldWidth = w;5606 int oldWidth = rect.width(); 5607 5607 adjustForBorderFit(0, left, right); 5608 5608 if (left != INT_MAX) { 5609 5609 left -= (borderLeft() + paddingLeft()); 5610 5610 if (left > 0) { 5611 x += left;5612 w -= left;5611 rect.move(left, 0); 5612 rect.expand(-left, 0); 5613 5613 } 5614 5614 } … … 5616 5616 right += (borderRight() + paddingRight()); 5617 5617 if (right < oldWidth) 5618 w -= (oldWidth - right);5618 rect.expand(-(oldWidth - right), 0); 5619 5619 } 5620 5620 } -
trunk/Source/WebCore/rendering/RenderBlock.h
r86160 r86377 361 361 BidiRun* handleTrailingSpaces(BidiRunList<BidiRun>&, BidiContext*); 362 362 363 virtual void borderFitAdjust( int& x, int& w) const; // Shrink the box in which the border paints if border-fit is set.363 virtual void borderFitAdjust(IntRect&) const; // Shrink the box in which the border paints if border-fit is set. 364 364 365 365 virtual void updateBeforeAfterContent(PseudoId); -
trunk/Source/WebCore/rendering/RenderBox.cpp
r86359 r86377 838 838 // border-fit can adjust where we paint our border and background. If set, we snugly fit our line box descendants. (The iChat 839 839 // balloon layout is an example of this). 840 borderFitAdjust( tx, width);840 borderFitAdjust(paintRect); 841 841 842 842 // FIXME: Should eventually give the theme control over whether the box shadow should paint, since controls could have 843 843 // custom shadows of their own. 844 paintBoxShadow(paintInfo.context, tx, ty, width, height, style(), Normal);844 paintBoxShadow(paintInfo.context, paintRect.x(), paintRect.y(), paintRect.width(), paintRect.height(), style(), Normal); 845 845 846 846 BackgroundBleedAvoidance bleedAvoidance = determineBackgroundBleedAvoidance(paintInfo.context); … … 871 871 theme()->paintDecorations(this, paintInfo, paintRect); 872 872 } 873 paintBoxShadow(paintInfo.context, tx, ty, width, height, style(), Inset);873 paintBoxShadow(paintInfo.context, paintRect.x(), paintRect.y(), paintRect.width(), paintRect.height(), style(), Inset); 874 874 875 875 // The theme will tell us whether or not we should also paint the CSS border. 876 876 if ((!style()->hasAppearance() || (!themePainted && theme()->paintBorderOnly(this, paintInfo, paintRect))) && style()->hasBorder()) 877 paintBorder(paintInfo.context, IntRect(tx, ty, width, height), style(), bleedAvoidance);877 paintBorder(paintInfo.context, paintRect, style(), bleedAvoidance); 878 878 879 879 if (bleedAvoidance == BackgroundBleedUseTransparencyLayer) … … 881 881 } 882 882 883 void RenderBox::paintMask(PaintInfo& paintInfo, int tx, int ty)883 void RenderBox::paintMask(PaintInfo& paintInfo, IntSize paintOffset) 884 884 { 885 885 if (!paintInfo.shouldPaintWithinRoot(this) || style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask || paintInfo.context->paintingDisabled()) 886 886 return; 887 887 888 int w = width(); 889 int h = height(); 888 IntRect paintRect = IntRect(toPoint(paintOffset), size()); 890 889 891 890 // border-fit can adjust where we paint our border and background. If set, we snugly fit our line box descendants. (The iChat 892 891 // balloon layout is an example of this). 893 borderFitAdjust( tx, w);894 895 paintMaskImages(paintInfo, tx, ty, w, h);896 } 897 898 void RenderBox::paintMaskImages(const PaintInfo& paintInfo, int tx, int ty, int w, int h)892 borderFitAdjust(paintRect); 893 894 paintMaskImages(paintInfo, paintRect); 895 } 896 897 void RenderBox::paintMaskImages(const PaintInfo& paintInfo, const IntRect& paintRect) 899 898 { 900 899 // Figure out if we need to push a transparency layer to render our mask. … … 954 953 955 954 if (allMaskImagesLoaded) { 956 IntRect paintRect = IntRect(tx, ty, w, h);957 955 paintFillLayers(paintInfo, Color(), style()->maskLayers(), paintRect, BackgroundBleedNone, compositeOp); 958 956 paintNinePieceImage(paintInfo.context, paintRect, style(), style()->maskBoxImage(), compositeOp); -
trunk/Source/WebCore/rendering/RenderBox.h
r86303 r86377 253 253 int computeContentBoxLogicalHeight(int height) const; 254 254 255 virtual void borderFitAdjust( int& /*x*/, int& /*w*/) const { } // Shrink the box in which the border paints if border-fit is set.255 virtual void borderFitAdjust(IntRect&) const { } // Shrink the box in which the border paints if border-fit is set. 256 256 257 257 // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end … … 346 346 virtual void paintObject(PaintInfo&, int /*tx*/, int /*ty*/) { ASSERT_NOT_REACHED(); } 347 347 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); 348 virtual void paintMask(PaintInfo&, int tx, int ty);348 virtual void paintMask(PaintInfo&, IntSize); 349 349 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0); 350 350 … … 410 410 411 411 void paintBoxDecorationsWithSize(PaintInfo&, int tx, int ty, int width, int height); 412 void paintMaskImages(const PaintInfo&, int tx, int ty, int width, int height);412 void paintMaskImages(const PaintInfo&, const IntRect&); 413 413 414 414 #if PLATFORM(MAC) -
trunk/Source/WebCore/rendering/RenderFieldset.cpp
r86303 r86377 171 171 } 172 172 173 void RenderFieldset::paintMask(PaintInfo& paintInfo, int tx, int ty)173 void RenderFieldset::paintMask(PaintInfo& paintInfo, IntSize paintOffset) 174 174 { 175 175 if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 176 176 return; 177 177 178 int w = width();179 int h = height();178 IntRect paintRect = IntRect(toPoint(paintOffset), size()); 179 IntSize adjustedSize = size(); 180 180 RenderBox* legend = findLegend(); 181 181 if (!legend) 182 return RenderBlock::paintMask(paintInfo, tx, ty);182 return RenderBlock::paintMask(paintInfo, paintOffset); 183 183 184 184 // FIXME: We need to work with "rl" and "bt" block flow directions. In those … … 187 187 if (style()->isHorizontalWritingMode()) { 188 188 int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2; 189 h -= yOff;190 ty += yOff;189 paintRect.expand(0, -yOff); 190 paintRect.move(0, yOff); 191 191 } else { 192 192 int xOff = (legend->x() > 0) ? 0 : (legend->width() - borderLeft()) / 2; 193 w -= xOff;194 tx += xOff;195 } 196 197 paintMaskImages(paintInfo, tx, ty, w, h);193 paintRect.expand(-xOff, 0); 194 paintRect.move(xOff, 0); 195 } 196 197 paintMaskImages(paintInfo, paintRect); 198 198 } 199 199 -
trunk/Source/WebCore/rendering/RenderFieldset.h
r75537 r86377 46 46 47 47 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); 48 virtual void paintMask(PaintInfo&, int tx, int ty);48 virtual void paintMask(PaintInfo&, IntSize); 49 49 }; 50 50 -
trunk/Source/WebCore/rendering/RenderReplaced.cpp
r77397 r86377 107 107 108 108 if (paintInfo.phase == PaintPhaseMask) { 109 paintMask(paintInfo, tx, ty);109 paintMask(paintInfo, IntSize(tx, ty)); 110 110 return; 111 111 } -
trunk/Source/WebCore/rendering/RenderReplica.cpp
r72850 r86377 77 77 RenderLayer::PaintLayerHaveTransparency | RenderLayer::PaintLayerAppliedTransform | RenderLayer::PaintLayerTemporaryClipRects | RenderLayer::PaintLayerPaintingReflection); 78 78 else if (paintInfo.phase == PaintPhaseMask) 79 paintMask(paintInfo, tx, ty);79 paintMask(paintInfo, IntSize(tx, ty)); 80 80 } 81 81 -
trunk/Source/WebCore/rendering/RenderTable.cpp
r86303 r86377 481 481 482 482 if (paintPhase == PaintPhaseMask) { 483 paintMask(paintInfo, tx, ty);483 paintMask(paintInfo, IntSize(tx, ty)); 484 484 return; 485 485 } … … 574 574 } 575 575 576 void RenderTable::paintMask(PaintInfo& paintInfo, int tx, int ty)576 void RenderTable::paintMask(PaintInfo& paintInfo, IntSize paintOffset) 577 577 { 578 578 if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 579 579 return; 580 580 581 IntRect rect(t x, ty, width(), height());581 IntRect rect(toPoint(paintOffset), size()); 582 582 subtractCaptionRect(rect); 583 583 584 paintMaskImages(paintInfo, rect .x(), rect.y(), rect.width(), rect.height());584 paintMaskImages(paintInfo, rect); 585 585 } 586 586 -
trunk/Source/WebCore/rendering/RenderTable.h
r86197 r86377 218 218 virtual void paintObject(PaintInfo&, int tx, int ty); 219 219 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); 220 virtual void paintMask(PaintInfo&, int tx, int ty);220 virtual void paintMask(PaintInfo&, IntSize); 221 221 virtual void layout(); 222 222 virtual void computePreferredLogicalWidths(); -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r86303 r86377 1024 1024 } 1025 1025 1026 void RenderTableCell::paintMask(PaintInfo& paintInfo, int tx, int ty)1026 void RenderTableCell::paintMask(PaintInfo& paintInfo, IntSize paintOffset) 1027 1027 { 1028 1028 if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) … … 1032 1032 if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild()) 1033 1033 return; 1034 1035 int w = width();1036 int h = height();1037 1034 1038 paintMaskImages(paintInfo, tx, ty, w, h);1035 paintMaskImages(paintInfo, IntRect(toPoint(paintOffset), size())); 1039 1036 } 1040 1037 -
trunk/Source/WebCore/rendering/RenderTableCell.h
r81747 r86377 144 144 145 145 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty); 146 virtual void paintMask(PaintInfo&, int tx, int ty);146 virtual void paintMask(PaintInfo&, IntSize); 147 147 148 148 virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const; -
trunk/Source/WebCore/rendering/RenderWidget.cpp
r86197 r86377 259 259 260 260 if (paintInfo.phase == PaintPhaseMask) { 261 paintMask(paintInfo, tx, ty);261 paintMask(paintInfo, IntSize(tx, ty)); 262 262 return; 263 263 }
Note: See TracChangeset
for help on using the changeset viewer.