Changeset 111515 in webkit
- Timestamp:
- Mar 21, 2012 2:32:01 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r111512 r111515 1 2012-03-21 Levi Weintraub <leviw@chromium.org> 2 3 Update LayoutUnit usage in descendants of RenderReplaced 4 https://bugs.webkit.org/show_bug.cgi?id=80918 5 6 Reviewed by Eric Seidel. 7 8 Replaced elements have to flow in the new sub-pixel Render Tree, but since the rendering of these 9 often takes place outside of WebCore (or in cases such as foreign objects, in WebCore after 10 passing through platform code), care must be taken to determine the final rendered size and 11 location before render time. This patch brings these classes up to the latest and greatest in the 12 subpixellayout branch. 13 14 See https://trac.webkit.org/wiki/LayoutUnit for more information. 15 16 No new tests. No change in behavior. 17 18 * rendering/RenderFrameBase.cpp: 19 (WebCore::RenderFrameBase::layoutWithFlattening): Build Fix. 20 * rendering/RenderFullScreen.cpp: 21 (RenderFullScreen::createPlaceholder): Ditto. 22 * rendering/RenderFullScreen.h: 23 (RenderFullScreen): Ditto. 24 * rendering/RenderHTMLCanvas.cpp: 25 (WebCore::RenderHTMLCanvas::canvasSizeChanged): Ditto. 26 * rendering/RenderIFrame.cpp: 27 (WebCore::RenderIFrame::computeLogicalHeight): Ditto. 28 (WebCore::RenderIFrame::computeLogicalWidth): Ditto. 29 * rendering/RenderImage.cpp: 30 (WebCore::RenderImage::updateIntrinsicSizeIfNeeded): Intrinsic sizes are always integers, since they 31 originate outside of WebCore. 32 (WebCore::RenderImage::paintIntoRect): Use pixel snapping to paint into an arbitrary rect. 33 (WebCore::RenderImage::computeReplacedLogicalWidth): Intrinsic size is always integral -- rounding 34 values to integers. 35 * rendering/RenderImage.h: 36 (RenderImage): 37 * rendering/RenderVideo.cpp: 38 (WebCore::RenderVideo::videoBox): 39 (WebCore::RenderVideo::paintReplaced): Painting at integer boundaries. 40 * rendering/RenderWidget.cpp: 41 (WebCore): 42 (WebCore::roundedIntRect): Widgets are rendered outside of WebCore, so we always align them to 43 integer boundaries. This means we can actually round the size of our ultimate content box. This 44 function is implemented here specifically to prevent its misuse if we put it elsewhere. 45 (WebCore::RenderWidget::setWidgetGeometry): We simplify layout by taking a LayoutRect and rounding 46 it to its final location within this function. 47 (WebCore::RenderWidget::updateWidgetGeometry): We keep things in LayoutUnits until handing off to 48 setWidgetGeometry. 49 (WebCore::RenderWidget::paint): Rounding the paint location before handing painting off to the 50 widget itself. 51 * rendering/RenderWidget.h: 52 (RenderWidget): 53 1 54 2012-03-21 Ilya Tikhonovsky <loislo@chromium.org> 2 55 -
trunk/Source/WebCore/rendering/RenderFrameBase.cpp
r86451 r111515 79 79 // expand the frame by setting frame height = content height 80 80 if (isScrollable || !fixedHeight || childRoot->isFrameSet()) 81 setHeight(max (height(), childFrameView->contentsHeight() + vBorder));81 setHeight(max<LayoutUnit>(height(), childFrameView->contentsHeight() + vBorder)); 82 82 if (isScrollable || !fixedWidth || childRoot->isFrameSet()) 83 setWidth(max (width(), childFrameView->contentsWidth() + hBorder));83 setWidth(max<LayoutUnit>(width(), childFrameView->contentsWidth() + hBorder)); 84 84 85 85 updateWidgetPosition(); -
trunk/Source/WebCore/rendering/RenderFullScreen.cpp
r104589 r111515 141 141 } 142 142 143 void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const IntRect& frameRect)143 void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const LayoutRect& frameRect) 144 144 { 145 145 if (style->width().isAuto()) -
trunk/Source/WebCore/rendering/RenderFullScreen.h
r95901 r111515 40 40 void setPlaceholder(RenderBlock*); 41 41 RenderBlock* placeholder() { return m_placeholder; } 42 void createPlaceholder(PassRefPtr<RenderStyle>, const IntRect& frameRect);42 void createPlaceholder(PassRefPtr<RenderStyle>, const LayoutRect& frameRect); 43 43 44 44 -
trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp
r109273 r111515 89 89 setPreferredLogicalWidthsDirty(true); 90 90 91 IntSize oldSize = size();91 LayoutSize oldSize = size(); 92 92 computeLogicalWidth(); 93 93 computeLogicalHeight(); -
trunk/Source/WebCore/rendering/RenderIFrame.cpp
r110718 r111515 58 58 return; 59 59 int border = borderTop() + borderBottom(); 60 setHeight(max (height(), view->contentsHeight() + border));60 setHeight(max<LayoutUnit>(height(), view->contentsHeight() + border)); 61 61 } 62 62 } … … 76 76 return; 77 77 LayoutUnit border = borderLeft() + borderRight(); 78 setWidth(max (width(), view->contentsWidth() + border));78 setWidth(max<LayoutUnit>(width(), view->contentsWidth() + border)); 79 79 } 80 80 } -
trunk/Source/WebCore/rendering/RenderImage.cpp
r110218 r111515 176 176 } 177 177 178 bool RenderImage::updateIntrinsicSizeIfNeeded(const LayoutSize& newSize, bool imageSizeChanged)178 bool RenderImage::updateIntrinsicSizeIfNeeded(const IntSize& newSize, bool imageSizeChanged) 179 179 { 180 180 if (newSize == intrinsicSize() && !imageSizeChanged) … … 417 417 void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect) 418 418 { 419 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || rect.width() <= 0 || rect.height() <= 0) 420 return; 421 422 RefPtr<Image> img = m_imageResource->image(rect.width(), rect.height()); 419 IntRect alignedRect = pixelSnappedIntRect(rect); 420 if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || alignedRect.width() <= 0 || alignedRect.height() <= 0) 421 return; 422 423 RefPtr<Image> img = m_imageResource->image(alignedRect.width(), alignedRect.height()); 423 424 if (!img || img->isNull()) 424 425 return; … … 427 428 CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator() : CompositeSourceOver; 428 429 Image* image = m_imageResource->image().get(); 429 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, rect.size());430 context->drawImage(m_imageResource->image( rect.width(), rect.height()).get(), style()->colorSpace(), rect, compositeOperator, useLowQualityScaling);430 bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, alignedRect.size()); 431 context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.height()).get(), style()->colorSpace(), alignedRect, compositeOperator, useLowQualityScaling); 431 432 } 432 433 … … 526 527 containerSize = cachedImage->image()->size(); 527 528 // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656 528 containerSize.setWidth( static_cast<LayoutUnit>(containerSize.width() * style()->effectiveZoom()));529 containerSize.setHeight( static_cast<LayoutUnit>(containerSize.height() * style()->effectiveZoom()));529 containerSize.setWidth(roundToInt(containerSize.width() * style()->effectiveZoom())); 530 containerSize.setHeight(roundToInt(containerSize.height() * style()->effectiveZoom())); 530 531 } 531 532 } -
trunk/Source/WebCore/rendering/RenderImage.h
r105513 r111515 95 95 IntSize imageSizeForError(CachedImage*) const; 96 96 void imageDimensionsChanged(bool imageSizeChanged, const IntRect* = 0); 97 bool updateIntrinsicSizeIfNeeded(const LayoutSize&, bool imageSizeChanged);97 bool updateIntrinsicSizeIfNeeded(const IntSize&, bool imageSizeChanged); 98 98 99 99 void paintAreaElementFocusRing(PaintInfo&); -
trunk/Source/WebCore/rendering/RenderVideo.cpp
r110218 r111515 167 167 elementSize = intrinsicSize(); 168 168 169 IntRect contentRect = contentBoxRect();169 IntRect contentRect = pixelSnappedIntRect(contentBoxRect()); 170 170 if (elementSize.isEmpty() || contentRect.isEmpty()) 171 171 return IntRect(); … … 226 226 paintIntoRect(paintInfo.context, rect); 227 227 else if (document()->view() && document()->view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers) 228 mediaPlayer->paintCurrentFrameInContext(paintInfo.context, rect);228 mediaPlayer->paintCurrentFrameInContext(paintInfo.context, pixelSnappedIntRect(rect)); 229 229 else 230 mediaPlayer->paint(paintInfo.context, rect);230 mediaPlayer->paint(paintInfo.context, pixelSnappedIntRect(rect)); 231 231 } 232 232 -
trunk/Source/WebCore/rendering/RenderWidget.cpp
r110323 r111515 141 141 } 142 142 143 bool RenderWidget::setWidgetGeometry(const IntRect& frame) 143 // Widgets are always placed on integer boundaries, so rounding the size is actually 144 // the desired behavior. This function is here because it's otherwise seldom what we 145 // want to do with a LayoutRect. 146 static inline IntRect roundedIntRect(const LayoutRect& rect) 147 { 148 return IntRect(roundedIntPoint(rect.location()), roundedIntSize(rect.size())); 149 } 150 151 bool RenderWidget::setWidgetGeometry(const LayoutRect& frame) 144 152 { 145 153 if (!node()) 146 154 return false; 147 155 148 IntRect clipRect = enclosingLayer()->childrenClipRect();156 IntRect clipRect = roundedIntRect(enclosingLayer()->childrenClipRect()); 149 157 bool clipChanged = m_clipRect != clipRect; 150 158 bool boundsChanged = m_widget->frameRect() != frame; … … 157 165 RenderWidgetProtector protector(this); 158 166 RefPtr<Node> protectedNode(node()); 159 m_widget->setFrameRect( frame);167 m_widget->setFrameRect(roundedIntRect(frame)); 160 168 161 169 #if USE(ACCELERATED_COMPOSITING) … … 169 177 bool RenderWidget::updateWidgetGeometry() 170 178 { 171 IntRect contentBox = contentBoxRect();179 LayoutRect contentBox = contentBoxRect(); 172 180 if (!m_widget->transformsAffectFrameRect()) 173 181 return setWidgetGeometry(absoluteContentBox()); 174 182 175 IntRect absoluteContentBox = IntRect(localToAbsoluteQuad(FloatQuad(contentBox)).boundingBox());183 LayoutRect absoluteContentBox(localToAbsoluteQuad(FloatQuad(contentBox)).boundingBox()); 176 184 if (m_widget->isFrameView()) { 177 185 contentBox.setLocation(absoluteContentBox.location()); … … 277 285 // Tell the widget to paint now. This is the only time the widget is allowed 278 286 // to paint itself. That way it will composite properly with z-indexed layers. 279 LayoutPoint widgetLocation = m_widget->frameRect().location(); 280 LayoutPoint paintLocation(adjustedPaintOffset.x() + borderLeft() + paddingLeft(), adjustedPaintOffset.y() + borderTop() + paddingTop()); 281 LayoutRect paintRect = paintInfo.rect; 282 283 LayoutSize widgetPaintOffset = paintLocation - widgetLocation; 287 IntPoint widgetLocation = m_widget->frameRect().location(); 288 IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + paddingLeft()), 289 roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop())); 290 IntRect paintRect = paintInfo.rect; 291 292 IntSize widgetPaintOffset = paintLocation - widgetLocation; 284 293 // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer, 285 294 // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing. -
trunk/Source/WebCore/rendering/RenderWidget.h
r98304 r111515 71 71 virtual void setOverlapTestResult(bool); 72 72 73 bool setWidgetGeometry(const IntRect&);73 bool setWidgetGeometry(const LayoutRect&); 74 74 bool updateWidgetGeometry(); 75 75
Note: See TracChangeset
for help on using the changeset viewer.