Changeset 88033 in webkit
- Timestamp:
- Jun 3, 2011 11:43:15 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r88029 r88033 1 2011-06-03 Levi Weintraub <leviw@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Switch paintBoxDecorations to IntPoint 6 https://bugs.webkit.org/show_bug.cgi?id=61968 7 8 Switching paintBoxDecorations to take an IntPoint representing 9 the paint offset instead of a pair of ints. Also cleaning up 10 some duplicated code in InlineFlowBox related to constraining 11 the paint rect to the linetop and linebottom. 12 13 No new tests since this is just refactoring. 14 15 * rendering/InlineFlowBox.cpp: 16 (WebCore::InlineFlowBox::paint): 17 (WebCore::InlineFlowBox::constrainToLineTopAndBottomIfNeeded): Added 18 to remove duplicate code in paintBoxDecorations and paintMask. 19 (WebCore::InlineFlowBox::paintBoxDecorations): 20 (WebCore::InlineFlowBox::paintMask): 21 * rendering/InlineFlowBox.h: 22 * rendering/RenderBlock.cpp: 23 (WebCore::RenderBlock::paintObject): 24 * rendering/RenderBox.cpp: 25 (WebCore::RenderBox::paintBoxDecorations): 26 * rendering/RenderBox.h: 27 * rendering/RenderFieldset.cpp: 28 (WebCore::RenderFieldset::paintBoxDecorations): 29 * rendering/RenderFieldset.h: 30 * rendering/RenderReplaced.cpp: 31 (WebCore::RenderReplaced::paint): 32 * rendering/RenderTable.cpp: 33 (WebCore::RenderTable::paintObject): 34 (WebCore::RenderTable::paintBoxDecorations): 35 * rendering/RenderTable.h: 36 * rendering/RenderTableCell.cpp: 37 (WebCore::RenderTableCell::paintBoxDecorations): 38 * rendering/RenderTableCell.h: 39 * rendering/RenderView.cpp: 40 (WebCore::RenderView::paintBoxDecorations): 41 * rendering/RenderView.h: 42 * rendering/RenderWidget.cpp: 43 (WebCore::RenderWidget::paint): 44 * rendering/svg/RenderSVGRoot.cpp: 45 (WebCore::RenderSVGRoot::paint): 46 1 47 2011-06-03 Doreen Jiang <doreen.jiang@nokia.com> 2 48 -
trunk/Source/WebCore/rendering/InlineFlowBox.cpp
r87989 r88033 996 996 } else { 997 997 // Paint our background, border and box-shadow. 998 paintBoxDecorations(paintInfo, paintOffset .x(), paintOffset.y());998 paintBoxDecorations(paintInfo, paintOffset); 999 999 } 1000 1000 } … … 1075 1075 } 1076 1076 1077 void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) 1077 void InlineFlowBox::constrainToLineTopAndBottomIfNeeded(IntRect& rect) const 1078 { 1079 bool noQuirksMode = renderer()->document()->inNoQuirksMode(); 1080 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) { 1081 const RootInlineBox* rootBox = root(); 1082 int logicalTop = isHorizontal() ? rect.y() : rect.x(); 1083 int logicalHeight = isHorizontal() ? rect.height() : rect.width(); 1084 int bottom = min(rootBox->lineBottom(), logicalTop + logicalHeight); 1085 logicalTop = max(rootBox->lineTop(), logicalTop); 1086 logicalHeight = bottom - logicalTop; 1087 if (isHorizontal()) { 1088 rect.setY(logicalTop); 1089 rect.setHeight(logicalHeight); 1090 } else { 1091 rect.setX(logicalTop); 1092 rect.setWidth(logicalHeight); 1093 } 1094 } 1095 } 1096 1097 void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset) 1078 1098 { 1079 1099 if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground) … … 1082 1102 // Pixel snap background/border painting. 1083 1103 IntRect frameRect = roundedFrameRect(); 1084 int x = frameRect.x(); 1085 int y = frameRect.y(); 1086 int w = frameRect.width(); 1087 int h = frameRect.height(); 1088 1089 // Constrain our background/border painting to the line top and bottom if necessary. 1090 bool noQuirksMode = renderer()->document()->inNoQuirksMode(); 1091 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) { 1092 RootInlineBox* rootBox = root(); 1093 int& top = isHorizontal() ? y : x; 1094 int& logicalHeight = isHorizontal() ? h : w; 1095 int bottom = min(rootBox->lineBottom(), top + logicalHeight); 1096 top = max(rootBox->lineTop(), top); 1097 logicalHeight = bottom - top; 1098 } 1104 1105 constrainToLineTopAndBottomIfNeeded(frameRect); 1099 1106 1100 1107 // Move x/y to our coordinates. 1101 IntRect localRect( x, y, w, h);1108 IntRect localRect(frameRect); 1102 1109 flipForWritingMode(localRect); 1103 tx += localRect.x(); 1104 ty += localRect.y(); 1110 IntPoint adjustedPaintoffset = paintOffset + localRect.location(); 1105 1111 1106 1112 GraphicsContext* context = paintInfo.context; … … 1110 1116 RenderStyle* styleToUse = renderer()->style(m_firstLine); 1111 1117 if ((!parent() && m_firstLine && styleToUse != renderer()->style()) || (parent() && renderer()->hasBoxDecorations())) { 1112 IntRect paintRect = IntRect( tx, ty, w, h);1118 IntRect paintRect = IntRect(adjustedPaintoffset, frameRect.size()); 1113 1119 // Shadow comes first and is behind the background and border. 1114 1120 paintBoxShadow(context, styleToUse, Normal, paintRect); … … 1145 1151 for (InlineFlowBox* curr = this; curr; curr = curr->nextLineBox()) 1146 1152 totalLogicalWidth += curr->logicalWidth(); 1147 int stripX = tx- (isHorizontal() ? logicalOffsetOnLine : 0);1148 int stripY = ty- (isHorizontal() ? 0 : logicalOffsetOnLine);1149 int stripWidth = isHorizontal() ? totalLogicalWidth : w;1150 int stripHeight = isHorizontal() ? h: totalLogicalWidth;1153 int stripX = adjustedPaintoffset.x() - (isHorizontal() ? logicalOffsetOnLine : 0); 1154 int stripY = adjustedPaintoffset.y() - (isHorizontal() ? 0 : logicalOffsetOnLine); 1155 int stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.width(); 1156 int stripHeight = isHorizontal() ? frameRect.height() : totalLogicalWidth; 1151 1157 1152 1158 GraphicsContextStateSaver stateSaver(*context); 1153 context->clip( IntRect(tx, ty, w, h));1159 context->clip(paintRect); 1154 1160 boxModelObject()->paintBorder(context, IntRect(stripX, stripY, stripWidth, stripHeight), renderer()->style()); 1155 1161 } … … 1165 1171 // Pixel snap mask painting. 1166 1172 IntRect frameRect = roundedFrameRect(); 1167 int x = frameRect.x(); 1168 int y = frameRect.y(); 1169 int w = frameRect.width(); 1170 int h = frameRect.height(); 1171 1172 // Constrain our background/border painting to the line top and bottom if necessary. 1173 bool noQuirksMode = renderer()->document()->inNoQuirksMode(); 1174 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) { 1175 RootInlineBox* rootBox = root(); 1176 int& top = isHorizontal() ? y : x; 1177 int& logicalHeight = isHorizontal() ? h : w; 1178 int bottom = min(rootBox->lineBottom(), top + logicalHeight); 1179 top = max(rootBox->lineTop(), top); 1180 logicalHeight = bottom - top; 1181 } 1173 1174 constrainToLineTopAndBottomIfNeeded(frameRect); 1182 1175 1183 1176 // Move x/y to our coordinates. 1184 IntRect localRect( x, y, w, h);1177 IntRect localRect(frameRect); 1185 1178 flipForWritingMode(localRect); 1186 1179 tx += localRect.x(); … … 1206 1199 } 1207 1200 1208 paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), IntRect(tx, ty, w, h), compositeOp); 1201 IntRect paintRect = IntRect(IntPoint(tx, ty), frameRect.size()); 1202 paintFillLayers(paintInfo, Color(), renderer()->style()->maskLayers(), paintRect, compositeOp); 1209 1203 1210 1204 bool hasBoxImage = maskBoxImage && maskBoxImage->canRender(renderer()->style()->effectiveZoom()); … … 1215 1209 // cases only a single call to draw is required. 1216 1210 if (!prevLineBox() && !nextLineBox()) { 1217 boxModelObject()->paintNinePieceImage(paintInfo.context, IntRect( tx, ty, w, h), renderer()->style(), maskNinePieceImage, compositeOp);1211 boxModelObject()->paintNinePieceImage(paintInfo.context, IntRect(IntPoint(tx, ty), frameRect.size()), renderer()->style(), maskNinePieceImage, compositeOp); 1218 1212 } else { 1219 1213 // We have a mask image that spans multiple lines. … … 1227 1221 int stripX = tx - (isHorizontal() ? logicalOffsetOnLine : 0); 1228 1222 int stripY = ty - (isHorizontal() ? 0 : logicalOffsetOnLine); 1229 int stripWidth = isHorizontal() ? totalLogicalWidth : w;1230 int stripHeight = isHorizontal() ? h: totalLogicalWidth;1223 int stripWidth = isHorizontal() ? totalLogicalWidth : frameRect.width(); 1224 int stripHeight = isHorizontal() ? frameRect.height() : totalLogicalWidth; 1231 1225 1232 1226 GraphicsContextStateSaver stateSaver(*paintInfo.context); 1233 paintInfo.context->clip( IntRect(tx, ty, w, h));1227 paintInfo.context->clip(paintRect); 1234 1228 boxModelObject()->paintNinePieceImage(paintInfo.context, IntRect(stripX, stripY, stripWidth, stripHeight), renderer()->style(), maskNinePieceImage, compositeOp); 1235 1229 } -
trunk/Source/WebCore/rendering/InlineFlowBox.h
r87964 r88033 104 104 IntRect roundedFrameRect() const; 105 105 106 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);106 virtual void paintBoxDecorations(PaintInfo&, const IntPoint&); 107 107 virtual void paintMask(PaintInfo&, int tx, int ty); 108 108 void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const IntRect&, CompositeOperator = CompositeSourceOver); … … 277 277 void addTextBoxVisualOverflow(InlineTextBox*, GlyphOverflowAndFallbackFontsMap&, IntRect& logicalVisualOverflow); 278 278 void addReplacedChildOverflow(const InlineBox*, IntRect& logicalLayoutOverflow, IntRect& logicalVisualOverflow); 279 void constrainToLineTopAndBottomIfNeeded(IntRect&) const; 279 280 280 281 protected: -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r87989 r88033 2465 2465 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground) && style()->visibility() == VISIBLE) { 2466 2466 if (hasBoxDecorations()) 2467 paintBoxDecorations(paintInfo, tx, ty);2467 paintBoxDecorations(paintInfo, IntPoint(tx, ty)); 2468 2468 if (hasColumns()) 2469 2469 paintColumnRules(paintInfo, tx, ty); -
trunk/Source/WebCore/rendering/RenderBox.cpp
r87989 r88033 826 826 } 827 827 828 void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)828 void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset) 829 829 { 830 830 if (!paintInfo.shouldPaintWithinRoot(this)) 831 831 return; 832 IntRect paintRect( tx, ty, width(), height());832 IntRect paintRect(paintOffset, size()); 833 833 834 834 // border-fit can adjust where we paint our border and background. If set, we snugly fit our line box descendants. (The iChat -
trunk/Source/WebCore/rendering/RenderBox.h
r87881 r88033 354 354 355 355 virtual void paintObject(PaintInfo&, int /*tx*/, int /*ty*/) { ASSERT_NOT_REACHED(); } 356 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);356 virtual void paintBoxDecorations(PaintInfo&, const IntPoint&); 357 357 virtual void paintMask(PaintInfo&, IntSize); 358 358 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0); -
trunk/Source/WebCore/rendering/RenderFieldset.cpp
r86670 r88033 119 119 } 120 120 121 void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)121 void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset) 122 122 { 123 123 if (!paintInfo.shouldPaintWithinRoot(this)) 124 124 return; 125 125 126 int w = width(); 127 int h = height(); 126 IntRect paintRect(paintOffset, size()); 128 127 RenderBox* legend = findLegend(); 129 128 if (!legend) 130 return RenderBlock::paintBoxDecorations(paintInfo, tx, ty);129 return RenderBlock::paintBoxDecorations(paintInfo, paintOffset); 131 130 132 131 // FIXME: We need to work with "rl" and "bt" block flow directions. In those … … 135 134 if (style()->isHorizontalWritingMode()) { 136 135 int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2; 137 h -= yOff;138 ty += yOff;136 paintRect.setHeight(paintRect.height() - yOff); 137 paintRect.setY(paintRect.y() + yOff); 139 138 } else { 140 139 int xOff = (legend->x() > 0) ? 0 : (legend->width() - borderLeft()) / 2; 141 w -= xOff;142 tx += xOff;140 paintRect.setWidth(paintRect.width() - xOff); 141 paintRect.setX(paintRect.x() + xOff); 143 142 } 144 145 IntRect paintRect = IntRect(tx, ty, w, h);146 143 147 144 paintBoxShadow(paintInfo.context, paintRect, style(), Normal); … … 160 157 // https://bugs.webkit.org/show_bug.cgi?id=47236 161 158 if (style()->isHorizontalWritingMode()) { 162 int clipTop = ty;159 int clipTop = paintRect.y(); 163 160 int clipHeight = max(static_cast<int>(style()->borderTopWidth()), legend->height()); 164 graphicsContext->clipOut(IntRect( tx+ legend->x(), clipTop, legend->width(), clipHeight));161 graphicsContext->clipOut(IntRect(paintRect.x() + legend->x(), clipTop, legend->width(), clipHeight)); 165 162 } else { 166 int clipLeft = tx;163 int clipLeft = paintRect.x(); 167 164 int clipWidth = max(static_cast<int>(style()->borderLeftWidth()), legend->width()); 168 graphicsContext->clipOut(IntRect(clipLeft, ty+ legend->y(), clipWidth, legend->height()));165 graphicsContext->clipOut(IntRect(clipLeft, paintRect.y() + legend->y(), clipWidth, legend->height())); 169 166 } 170 167 -
trunk/Source/WebCore/rendering/RenderFieldset.h
r86377 r88033 45 45 virtual bool stretchesToMinIntrinsicLogicalWidth() const { return true; } 46 46 47 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);47 virtual void paintBoxDecorations(PaintInfo&, const IntPoint&); 48 48 virtual void paintMask(PaintInfo&, IntSize); 49 49 }; -
trunk/Source/WebCore/rendering/RenderReplaced.cpp
r87989 r88033 104 104 105 105 if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection)) 106 paintBoxDecorations(paintInfo, tx, ty);106 paintBoxDecorations(paintInfo, IntPoint(tx, ty)); 107 107 108 108 if (paintInfo.phase == PaintPhaseMask) { -
trunk/Source/WebCore/rendering/RenderTable.cpp
r87018 r88033 478 478 PaintPhase paintPhase = paintInfo.phase; 479 479 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground) && hasBoxDecorations() && style()->visibility() == VISIBLE) 480 paintBoxDecorations(paintInfo, tx, ty);480 paintBoxDecorations(paintInfo, IntPoint(tx, ty)); 481 481 482 482 if (paintPhase == PaintPhaseMask) { … … 551 551 } 552 552 553 void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)553 void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset) 554 554 { 555 555 if (!paintInfo.shouldPaintWithinRoot(this)) 556 556 return; 557 557 558 IntRect rect( tx, ty, width(), height());558 IntRect rect(paintOffset, size()); 559 559 subtractCaptionRect(rect); 560 560 -
trunk/Source/WebCore/rendering/RenderTable.h
r86705 r88033 217 217 virtual void paint(PaintInfo&, int tx, int ty); 218 218 virtual void paintObject(PaintInfo&, int tx, int ty); 219 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);219 virtual void paintBoxDecorations(PaintInfo&, const IntPoint&); 220 220 virtual void paintMask(PaintInfo&, IntSize); 221 221 virtual void layout(); -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r87989 r88033 1002 1002 } 1003 1003 1004 void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)1004 void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint& paintOffset) 1005 1005 { 1006 1006 if (!paintInfo.shouldPaintWithinRoot(this)) … … 1011 1011 return; 1012 1012 1013 IntRect paintRect = IntRect( IntPoint(tx, ty), size());1013 IntRect paintRect = IntRect(paintOffset, size()); 1014 1014 paintBoxShadow(paintInfo.context, paintRect, style(), Normal); 1015 1015 1016 1016 // Paint our cell background. 1017 paintBackgroundsBehindCell(paintInfo, tx, ty, this);1017 paintBackgroundsBehindCell(paintInfo, paintOffset.x(), paintOffset.y(), this); 1018 1018 1019 1019 paintBoxShadow(paintInfo.context, paintRect, style(), Inset); -
trunk/Source/WebCore/rendering/RenderTableCell.h
r86449 r88033 143 143 virtual void computeLogicalWidth(); 144 144 145 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);145 virtual void paintBoxDecorations(PaintInfo&, const IntPoint&); 146 146 virtual void paintMask(PaintInfo&, IntSize); 147 147 -
trunk/Source/WebCore/rendering/RenderView.cpp
r87989 r88033 185 185 } 186 186 187 void RenderView::paintBoxDecorations(PaintInfo& paintInfo, int, int)187 void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const IntPoint&) 188 188 { 189 189 // Check to see if we are enclosed by a layer that requires complex painting rules. If so, we cannot blit -
trunk/Source/WebCore/rendering/RenderView.h
r87277 r88033 71 71 72 72 virtual void paint(PaintInfo&, int tx, int ty); 73 virtual void paintBoxDecorations(PaintInfo&, int tx, int ty);73 virtual void paintBoxDecorations(PaintInfo&, const IntPoint&); 74 74 75 75 enum SelectionRepaintMode { RepaintNewXOROld, RepaintNewMinusOld }; -
trunk/Source/WebCore/rendering/RenderWidget.cpp
r87866 r88033 257 257 258 258 if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection)) 259 paintBoxDecorations(paintInfo, tx, ty);259 paintBoxDecorations(paintInfo, IntPoint(tx, ty)); 260 260 261 261 if (paintInfo.phase == PaintPhaseMask) { -
trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp
r88007 r88033 273 273 274 274 if (hasBoxDecorations() && (paintInfo.phase == PaintPhaseBlockBackground || paintInfo.phase == PaintPhaseChildBlockBackground) && isVisible) 275 paintBoxDecorations(paintInfo, borderBoxOriginInContainer .x(), borderBoxOriginInContainer.y());275 paintBoxDecorations(paintInfo, borderBoxOriginInContainer); 276 276 277 277 if (paintInfo.phase == PaintPhaseBlockBackground)
Note: See TracChangeset
for help on using the changeset viewer.