Changeset 89983 in webkit
- Timestamp:
- Jun 28, 2011 6:06:00 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r89982 r89983 1 2011-06-28 Levi Weintraub <leviw@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Switch paintObject and paintReplaced to new layout types 6 https://bugs.webkit.org/show_bug.cgi?id=63585 7 8 Switching paintObject and paintReplaced to layout type abstractions from more integral types. 9 10 No new tests as this is just moving to an abstraction. 11 12 * rendering/RenderBlock.cpp: 13 (WebCore::RenderBlock::paintObject): 14 * rendering/RenderBlock.h: 15 * rendering/RenderBox.h: 16 (WebCore::RenderBox::paintObject): 17 * rendering/RenderEmbeddedObject.cpp: 18 (WebCore::RenderEmbeddedObject::paintReplaced): 19 * rendering/RenderEmbeddedObject.h: 20 * rendering/RenderFileUploadControl.cpp: 21 (WebCore::RenderFileUploadControl::paintObject): 22 * rendering/RenderFileUploadControl.h: 23 * rendering/RenderHTMLCanvas.cpp: 24 (WebCore::RenderHTMLCanvas::paintReplaced): 25 * rendering/RenderHTMLCanvas.h: 26 * rendering/RenderImage.cpp: 27 (WebCore::RenderImage::paintReplaced): 28 * rendering/RenderImage.h: 29 * rendering/RenderListBox.cpp: 30 (WebCore::RenderListBox::paintObject): 31 * rendering/RenderListBox.h: 32 * rendering/RenderReplaced.h: 33 (WebCore::RenderReplaced::paintReplaced): 34 * rendering/RenderTable.cpp: 35 (WebCore::RenderTable::paintObject): 36 * rendering/RenderTable.h: 37 * rendering/RenderTableSection.cpp: 38 (WebCore::RenderTableSection::paintObject): 39 * rendering/RenderTableSection.h: 40 * rendering/RenderTextControl.cpp: 41 (WebCore::RenderTextControl::paintObject): 42 * rendering/RenderTextControl.h: 43 * rendering/RenderVideo.cpp: 44 (WebCore::RenderVideo::paintReplaced): 45 * rendering/RenderVideo.h: 46 1 47 2011-06-28 Adam Langley <agl@chromium.org> 2 48 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r89836 r89983 2480 2480 } 2481 2481 2482 void RenderBlock::paintObject(PaintInfo& paintInfo, const IntPoint& paintOffset)2482 void RenderBlock::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 2483 2483 { 2484 2484 PaintPhase paintPhase = paintInfo.phase; … … 2502 2502 2503 2503 // Adjust our painting position if we're inside a scrolled layer (e.g., an overflow:auto div). 2504 IntPoint scrolledOffset = paintOffset;2504 LayoutPoint scrolledOffset = paintOffset; 2505 2505 if (hasOverflowClip()) 2506 2506 scrolledOffset.move(-layer()->scrolledContentOffset()); -
trunk/Source/WebCore/rendering/RenderBlock.h
r89165 r89983 294 294 295 295 virtual void paint(PaintInfo&, const IntPoint&); 296 virtual void paintObject(PaintInfo&, const IntPoint&);296 virtual void paintObject(PaintInfo&, const LayoutPoint&); 297 297 298 298 int logicalRightOffsetForLine(int position, int fixedOffset, bool applyTextIndent = true, int* logicalHeightRemaining = 0) const; -
trunk/Source/WebCore/rendering/RenderBox.h
r89979 r89983 353 353 void popContentsClip(PaintInfo&, PaintPhase originalPhase, const IntPoint& accumulatedOffset); 354 354 355 virtual void paintObject(PaintInfo&, const IntPoint&) { ASSERT_NOT_REACHED(); }355 virtual void paintObject(PaintInfo&, const LayoutPoint&) { ASSERT_NOT_REACHED(); } 356 356 virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&); 357 357 virtual void paintMask(PaintInfo&, const LayoutPoint&); -
trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp
r88400 r89983 146 146 } 147 147 148 void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const IntPoint& paintOffset)148 void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 149 149 { 150 150 if (!pluginCrashedOrWasMissing()) -
trunk/Source/WebCore/rendering/RenderEmbeddedObject.h
r88400 r89983 57 57 virtual bool isEmbeddedObject() const { return true; } 58 58 59 virtual void paintReplaced(PaintInfo&, const IntPoint&);59 virtual void paintReplaced(PaintInfo&, const LayoutPoint&); 60 60 virtual void paint(PaintInfo&, const IntPoint&); 61 61 -
trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp
r89950 r89983 77 77 } 78 78 79 void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const IntPoint& paintOffset)79 void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 80 80 { 81 81 if (style()->visibility() != VISIBLE) … … 85 85 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); 86 86 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseChildBlockBackgrounds) { 87 IntRect clipRect(paintOffset.x() + borderLeft(), paintOffset.y() + borderTop(),87 LayoutRect clipRect(paintOffset.x() + borderLeft(), paintOffset.y() + borderTop(), 88 88 width() - borderLeft() - borderRight(), height() - borderBottom() - borderTop() + buttonShadowHeight); 89 89 if (clipRect.isEmpty()) … … 100 100 101 101 // Determine where the filename should be placed 102 int contentLeft = paintOffset.x() + borderLeft() + paddingLeft();102 LayoutUnit contentLeft = paintOffset.x() + borderLeft() + paddingLeft(); 103 103 HTMLInputElement* button = uploadButton(); 104 104 if (!button) … … 106 106 107 107 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); 108 int buttonWidth = nodeWidth(button);109 int buttonAndIconWidth = buttonWidth + afterButtonSpacing108 LayoutUnit buttonWidth = nodeWidth(button); 109 LayoutUnit buttonAndIconWidth = buttonWidth + afterButtonSpacing 110 110 + (input->icon() ? iconWidth + iconFilenameSpacing : 0); 111 int textX;111 LayoutUnit textX; 112 112 if (style()->isLeftToRightDirection()) 113 113 textX = contentLeft + buttonAndIconWidth; … … 116 116 // We want to match the button's baseline 117 117 RenderButton* buttonRenderer = toRenderButton(button->renderer()); 118 int textY = buttonRenderer->absoluteBoundingBoxRect().y()118 LayoutUnit textY = buttonRenderer->absoluteBoundingBoxRect().y() 119 119 + buttonRenderer->marginTop() + buttonRenderer->borderTop() + buttonRenderer->paddingTop() 120 120 + buttonRenderer->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine); … … 123 123 124 124 // Draw the filename 125 paintInfo.context->drawBidiText(font, textRun, IntPoint(textX, textY));125 paintInfo.context->drawBidiText(font, textRun, LayoutPoint(textX, textY)); 126 126 127 127 if (input->icon()) { 128 128 // Determine where the icon should be placed 129 int iconY = paintOffset.y() + borderTop() + paddingTop() + (contentHeight() - iconHeight) / 2;130 int iconX;129 LayoutUnit iconY = paintOffset.y() + borderTop() + paddingTop() + (contentHeight() - iconHeight) / 2; 130 LayoutUnit iconX; 131 131 if (style()->isLeftToRightDirection()) 132 132 iconX = contentLeft + buttonWidth + afterButtonSpacing; … … 135 135 136 136 // Draw the file icon 137 input->icon()->paint(paintInfo.context, IntRect(iconX, iconY, iconWidth, iconHeight));137 input->icon()->paint(paintInfo.context, LayoutRect(iconX, iconY, iconWidth, iconHeight)); 138 138 } 139 139 } -
trunk/Source/WebCore/rendering/RenderFileUploadControl.h
r89535 r89983 47 47 virtual void updateFromElement(); 48 48 virtual void computePreferredLogicalWidths(); 49 virtual void paintObject(PaintInfo&, const IntPoint&);49 virtual void paintObject(PaintInfo&, const LayoutPoint&); 50 50 51 51 virtual bool requiresForcedStyleRecalcPropagation() const { return true; } -
trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp
r87989 r89983 55 55 } 56 56 57 void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const IntPoint& paintOffset)57 void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 58 58 { 59 IntRect rect = contentBoxRect();59 LayoutRect rect = contentBoxRect(); 60 60 rect.moveBy(paintOffset); 61 61 bool useLowQualityScale = style()->imageRendering() == ImageRenderingOptimizeContrast; -
trunk/Source/WebCore/rendering/RenderHTMLCanvas.h
r87989 r89983 44 44 private: 45 45 virtual const char* renderName() const { return "RenderHTMLCanvas"; } 46 virtual void paintReplaced(PaintInfo&, const IntPoint&);46 virtual void paintReplaced(PaintInfo&, const LayoutPoint&); 47 47 virtual void intrinsicSizeChanged() { canvasSizeChanged(); } 48 48 }; -
trunk/Source/WebCore/rendering/RenderImage.cpp
r88319 r89983 232 232 } 233 233 234 void RenderImage::paintReplaced(PaintInfo& paintInfo, const IntPoint& paintOffset)235 { 236 int cWidth = contentWidth();237 int cHeight = contentHeight();238 int leftBorder = borderLeft();239 int topBorder = borderTop();240 int leftPad = paddingLeft();241 int topPad = paddingTop();234 void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 235 { 236 LayoutUnit cWidth = contentWidth(); 237 LayoutUnit cHeight = contentHeight(); 238 LayoutUnit leftBorder = borderLeft(); 239 LayoutUnit topBorder = borderTop(); 240 LayoutUnit leftPad = paddingLeft(); 241 LayoutUnit topPad = paddingTop(); 242 242 243 243 GraphicsContext* context = paintInfo.context; … … 252 252 context->setStrokeColor(Color::lightGray, style()->colorSpace()); 253 253 context->setFillColor(Color::transparent, style()->colorSpace()); 254 context->drawRect( IntRect(paintOffset.x() + leftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight));254 context->drawRect(LayoutRect(paintOffset.x() + leftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight)); 255 255 256 256 bool errorPictureDrawn = false; 257 IntSize imageOffset;257 LayoutSize imageOffset; 258 258 // When calculating the usable dimensions, exclude the pixels of 259 259 // the ouline rect so the error image/alt text doesn't draw on it. 260 int usableWidth = cWidth - 2;261 int usableHeight = cHeight - 2;260 LayoutUnit usableWidth = cWidth - 2; 261 LayoutUnit usableHeight = cHeight - 2; 262 262 263 263 RefPtr<Image> image = m_imageResource->image(); … … 265 265 if (m_imageResource->errorOccurred() && !image->isNull() && usableWidth >= image->width() && usableHeight >= image->height()) { 266 266 // Center the error image, accounting for border and padding. 267 int centerX = (usableWidth - image->width()) / 2;267 LayoutUnit centerX = (usableWidth - image->width()) / 2; 268 268 if (centerX < 0) 269 269 centerX = 0; 270 int centerY = (usableHeight - image->height()) / 2;270 LayoutUnit centerY = (usableHeight - image->height()) / 2; 271 271 if (centerY < 0) 272 272 centerY = 0; 273 imageOffset = IntSize(leftBorder + leftPad + centerX + 1, topBorder + topPad + centerY + 1);273 imageOffset = LayoutSize(leftBorder + leftPad + centerX + 1, topBorder + topPad + centerY + 1); 274 274 context->drawImage(image.get(), style()->colorSpace(), paintOffset + imageOffset); 275 275 errorPictureDrawn = true; … … 281 281 const Font& font = style()->font(); 282 282 const FontMetrics& fontMetrics = font.fontMetrics(); 283 int ascent = fontMetrics.ascent();284 IntPoint altTextOffset = paintOffset;283 LayoutUnit ascent = fontMetrics.ascent(); 284 LayoutPoint altTextOffset = paintOffset; 285 285 altTextOffset.move(leftBorder + leftPad, topBorder + topPad + ascent); 286 286 … … 288 288 // and only if it fits above the error image. 289 289 TextRun textRun = RenderBlock::constructTextRun(this, font, text, style()); 290 int textWidth = font.width(textRun);290 LayoutUnit textWidth = font.width(textRun); 291 291 if (errorPictureDrawn) { 292 292 if (usableWidth >= textWidth && fontMetrics.height() <= imageOffset.height()) … … 306 306 #endif 307 307 308 IntSize contentSize(cWidth, cHeight);309 IntPoint contentLocation = paintOffset;308 LayoutSize contentSize(cWidth, cHeight); 309 LayoutPoint contentLocation = paintOffset; 310 310 contentLocation.move(leftBorder + leftPad, topBorder + topPad); 311 paintIntoRect(context, IntRect(contentLocation, contentSize));311 paintIntoRect(context, LayoutRect(contentLocation, contentSize)); 312 312 } 313 313 } -
trunk/Source/WebCore/rendering/RenderImage.h
r88319 r89983 77 77 virtual bool isRenderImage() const { return true; } 78 78 79 virtual void paintReplaced(PaintInfo&, const IntPoint&);79 virtual void paintReplaced(PaintInfo&, const LayoutPoint&); 80 80 81 81 virtual int minimumReplacedHeight() const; -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r89733 r89983 262 262 } 263 263 264 void RenderListBox::paintObject(PaintInfo& paintInfo, const IntPoint& paintOffset)264 void RenderListBox::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 265 265 { 266 266 if (style()->visibility() != VISIBLE) -
trunk/Source/WebCore/rendering/RenderListBox.h
r88982 r89983 66 66 67 67 virtual bool hasControlClip() const { return true; } 68 virtual void paintObject(PaintInfo&, const IntPoint&);68 virtual void paintObject(PaintInfo&, const LayoutPoint&); 69 69 virtual IntRect controlClipRect(const IntPoint&) const; 70 70 -
trunk/Source/WebCore/rendering/RenderReplaced.h
r88913 r89983 71 71 int calcAspectRatioLogicalHeight() const; 72 72 73 virtual void paintReplaced(PaintInfo&, const IntPoint&) { }73 virtual void paintReplaced(PaintInfo&, const LayoutPoint&) { } 74 74 75 75 virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer); -
trunk/Source/WebCore/rendering/RenderTable.cpp
r89979 r89983 473 473 } 474 474 475 void RenderTable::paintObject(PaintInfo& paintInfo, const IntPoint& paintOffset)475 void RenderTable::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 476 476 { 477 477 PaintPhase paintPhase = paintInfo.phase; … … 498 498 for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { 499 499 if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer() && (child->isTableSection() || child == m_caption)) { 500 IntPoint childPoint = flipForWritingMode(toRenderBox(child), paintOffset, ParentToChildFlippingAdjustment);500 LayoutPoint childPoint = flipForWritingMode(toRenderBox(child), paintOffset, ParentToChildFlippingAdjustment); 501 501 child->paint(info, childPoint); 502 502 } … … 520 520 for (RenderObject* child = firstChild(); child; child = child->nextSibling()) 521 521 if (child->isTableSection()) { 522 IntPoint childPoint = flipForWritingMode(toRenderTableSection(child), paintOffset, ParentToChildFlippingAdjustment);522 LayoutPoint childPoint = flipForWritingMode(toRenderTableSection(child), paintOffset, ParentToChildFlippingAdjustment); 523 523 child->paint(info, childPoint); 524 524 } … … 529 529 // Paint outline. 530 530 if ((paintPhase == PaintPhaseOutline || paintPhase == PaintPhaseSelfOutline) && hasOutline() && style()->visibility() == VISIBLE) 531 paintOutline(paintInfo.context, IntRect(paintOffset, size()));531 paintOutline(paintInfo.context, LayoutRect(paintOffset, size())); 532 532 } 533 533 -
trunk/Source/WebCore/rendering/RenderTable.h
r89974 r89983 216 216 217 217 virtual void paint(PaintInfo&, const IntPoint&); 218 virtual void paintObject(PaintInfo&, const IntPoint&);218 virtual void paintObject(PaintInfo&, const LayoutPoint&); 219 219 virtual void paintBoxDecorations(PaintInfo&, const IntPoint&); 220 220 virtual void paintMask(PaintInfo&, const LayoutPoint&); -
trunk/Source/WebCore/rendering/RenderTableSection.cpp
r88319 r89983 948 948 } 949 949 950 void RenderTableSection::paintObject(PaintInfo& paintInfo, const IntPoint& paintOffset)950 void RenderTableSection::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 951 951 { 952 952 // Check which rows and cols are visible and only paint these. … … 957 957 PaintPhase paintPhase = paintInfo.phase; 958 958 959 int os = 2 * maximalOutlineSize(paintPhase);959 LayoutUnit os = 2 * maximalOutlineSize(paintPhase); 960 960 unsigned startrow = 0; 961 961 unsigned endrow = totalRows; 962 962 963 IntRect localRepaintRect = paintInfo.rect;963 LayoutRect localRepaintRect = paintInfo.rect; 964 964 localRepaintRect.moveBy(-paintOffset); 965 965 if (style()->isFlippedBlocksWritingMode()) { … … 972 972 // If some cell overflows, just paint all of them. 973 973 if (!m_hasOverflowingCell) { 974 int before = (style()->isHorizontalWritingMode() ? localRepaintRect.y() : localRepaintRect.x()) - os;974 LayoutUnit before = (style()->isHorizontalWritingMode() ? localRepaintRect.y() : localRepaintRect.x()) - os; 975 975 // binary search to find a row 976 976 startrow = std::lower_bound(m_rowPos.begin(), m_rowPos.end(), before) - m_rowPos.begin(); … … 982 982 --startrow; 983 983 984 int after = (style()->isHorizontalWritingMode() ? localRepaintRect.maxY() : localRepaintRect.maxX()) + os;984 LayoutUnit after = (style()->isHorizontalWritingMode() ? localRepaintRect.maxY() : localRepaintRect.maxX()) + os; 985 985 endrow = std::lower_bound(m_rowPos.begin(), m_rowPos.end(), after) - m_rowPos.begin(); 986 986 if (endrow == m_rowPos.size()) … … 995 995 // FIXME: Implement RTL. 996 996 if (!m_hasOverflowingCell && style()->isLeftToRightDirection()) { 997 int start = (style()->isHorizontalWritingMode() ? localRepaintRect.x() : localRepaintRect.y()) - os;997 LayoutUnit start = (style()->isHorizontalWritingMode() ? localRepaintRect.x() : localRepaintRect.y()) - os; 998 998 Vector<int>& columnPos = table()->columnPositions(); 999 999 startcol = std::lower_bound(columnPos.begin(), columnPos.end(), start) - columnPos.begin(); … … 1001 1001 --startcol; 1002 1002 1003 int end = (style()->isHorizontalWritingMode() ? localRepaintRect.maxX() : localRepaintRect.maxY()) + os;1003 LayoutUnit end = (style()->isHorizontalWritingMode() ? localRepaintRect.maxX() : localRepaintRect.maxY()) + os; 1004 1004 endcol = std::lower_bound(columnPos.begin(), columnPos.end(), end) - columnPos.begin(); 1005 1005 if (endcol == columnPos.size()) -
trunk/Source/WebCore/rendering/RenderTableSection.h
r88319 r89983 135 135 virtual void paint(PaintInfo&, const IntPoint&); 136 136 virtual void paintCell(RenderTableCell*, PaintInfo&, const IntPoint&); 137 virtual void paintObject(PaintInfo&, const IntPoint&);137 virtual void paintObject(PaintInfo&, const LayoutPoint&); 138 138 139 139 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0); -
trunk/Source/WebCore/rendering/RenderTextControl.cpp
r89950 r89983 633 633 } 634 634 635 void RenderTextControl::paintObject(PaintInfo& paintInfo, const IntPoint& paintOffset)635 void RenderTextControl::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 636 636 { 637 637 if (m_placeholderVisible && paintInfo.phase == PaintPhaseForeground) -
trunk/Source/WebCore/rendering/RenderTextControl.h
r89913 r89983 91 91 virtual bool canHaveChildren() const { return false; } 92 92 virtual bool avoidsFloats() const { return true; } 93 virtual void paintObject(PaintInfo&, const IntPoint&);93 virtual void paintObject(PaintInfo&, const LayoutPoint&); 94 94 95 95 virtual void addFocusRingRects(Vector<IntRect>&, const IntPoint&); -
trunk/Source/WebCore/rendering/RenderVideo.cpp
r89977 r89983 189 189 } 190 190 191 void RenderVideo::paintReplaced(PaintInfo& paintInfo, const IntPoint& paintOffset)191 void RenderVideo::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset) 192 192 { 193 193 MediaPlayer* mediaPlayer = mediaElement()->player(); … … 200 200 } 201 201 202 IntRect rect = videoBox();202 LayoutRect rect = videoBox(); 203 203 if (rect.isEmpty()) 204 204 return; -
trunk/Source/WebCore/rendering/RenderVideo.h
r89977 r89983 67 67 virtual bool isVideo() const { return true; } 68 68 69 virtual void paintReplaced(PaintInfo&, const IntPoint&);69 virtual void paintReplaced(PaintInfo&, const LayoutPoint&); 70 70 71 71 virtual void layout();
Note: See TracChangeset
for help on using the changeset viewer.