Changeset 111515 in webkit


Ignore:
Timestamp:
Mar 21, 2012 2:32:01 AM (12 years ago)
Author:
leviw@chromium.org
Message:

Update LayoutUnit usage in descendants of RenderReplaced
https://bugs.webkit.org/show_bug.cgi?id=80918

Reviewed by Eric Seidel.

Replaced elements have to flow in the new sub-pixel Render Tree, but since the rendering of these
often takes place outside of WebCore (or in cases such as foreign objects, in WebCore after
passing through platform code), care must be taken to determine the final rendered size and
location before render time. This patch brings these classes up to the latest and greatest in the
subpixellayout branch.

See https://trac.webkit.org/wiki/LayoutUnit for more information.

No new tests. No change in behavior.

  • rendering/RenderFrameBase.cpp:

(WebCore::RenderFrameBase::layoutWithFlattening): Build Fix.

  • rendering/RenderFullScreen.cpp:

(RenderFullScreen::createPlaceholder): Ditto.

  • rendering/RenderFullScreen.h:

(RenderFullScreen): Ditto.

  • rendering/RenderHTMLCanvas.cpp:

(WebCore::RenderHTMLCanvas::canvasSizeChanged): Ditto.

  • rendering/RenderIFrame.cpp:

(WebCore::RenderIFrame::computeLogicalHeight): Ditto.
(WebCore::RenderIFrame::computeLogicalWidth): Ditto.

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::updateIntrinsicSizeIfNeeded): Intrinsic sizes are always integers, since they
originate outside of WebCore.
(WebCore::RenderImage::paintIntoRect): Use pixel snapping to paint into an arbitrary rect.
(WebCore::RenderImage::computeReplacedLogicalWidth): Intrinsic size is always integral -- rounding
values to integers.

  • rendering/RenderImage.h:

(RenderImage):

  • rendering/RenderVideo.cpp:

(WebCore::RenderVideo::videoBox):
(WebCore::RenderVideo::paintReplaced): Painting at integer boundaries.

  • rendering/RenderWidget.cpp:

(WebCore):
(WebCore::roundedIntRect): Widgets are rendered outside of WebCore, so we always align them to
integer boundaries. This means we can actually round the size of our ultimate content box. This
function is implemented here specifically to prevent its misuse if we put it elsewhere.
(WebCore::RenderWidget::setWidgetGeometry): We simplify layout by taking a LayoutRect and rounding
it to its final location within this function.
(WebCore::RenderWidget::updateWidgetGeometry): We keep things in LayoutUnits until handing off to
setWidgetGeometry.
(WebCore::RenderWidget::paint): Rounding the paint location before handing painting off to the
widget itself.

  • rendering/RenderWidget.h:

(RenderWidget):

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r111512 r111515  
     12012-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
    1542012-03-21  Ilya Tikhonovsky  <loislo@chromium.org>
    255
  • trunk/Source/WebCore/rendering/RenderFrameBase.cpp

    r86451 r111515  
    7979    // expand the frame by setting frame height = content height
    8080    if (isScrollable || !fixedHeight || childRoot->isFrameSet())
    81         setHeight(max(height(), childFrameView->contentsHeight() + vBorder));
     81        setHeight(max<LayoutUnit>(height(), childFrameView->contentsHeight() + vBorder));
    8282    if (isScrollable || !fixedWidth || childRoot->isFrameSet())
    83         setWidth(max(width(), childFrameView->contentsWidth() + hBorder));
     83        setWidth(max<LayoutUnit>(width(), childFrameView->contentsWidth() + hBorder));
    8484
    8585    updateWidgetPosition();
  • trunk/Source/WebCore/rendering/RenderFullScreen.cpp

    r104589 r111515  
    141141}
    142142
    143 void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const IntRect& frameRect)
     143void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const LayoutRect& frameRect)
    144144{
    145145    if (style->width().isAuto())
  • trunk/Source/WebCore/rendering/RenderFullScreen.h

    r95901 r111515  
    4040    void setPlaceholder(RenderBlock*);
    4141    RenderBlock* placeholder() { return m_placeholder; }
    42     void createPlaceholder(PassRefPtr<RenderStyle>, const IntRect& frameRect);
     42    void createPlaceholder(PassRefPtr<RenderStyle>, const LayoutRect& frameRect);
    4343
    4444
  • trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp

    r109273 r111515  
    8989        setPreferredLogicalWidthsDirty(true);
    9090
    91     IntSize oldSize = size();
     91    LayoutSize oldSize = size();
    9292    computeLogicalWidth();
    9393    computeLogicalHeight();
  • trunk/Source/WebCore/rendering/RenderIFrame.cpp

    r110718 r111515  
    5858            return;
    5959        int border = borderTop() + borderBottom();
    60         setHeight(max(height(), view->contentsHeight() + border));
     60        setHeight(max<LayoutUnit>(height(), view->contentsHeight() + border));
    6161    }
    6262}
     
    7676            return;
    7777        LayoutUnit border = borderLeft() + borderRight();
    78         setWidth(max(width(), view->contentsWidth() + border));
     78        setWidth(max<LayoutUnit>(width(), view->contentsWidth() + border));
    7979    }
    8080}
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r110218 r111515  
    176176}
    177177
    178 bool RenderImage::updateIntrinsicSizeIfNeeded(const LayoutSize& newSize, bool imageSizeChanged)
     178bool RenderImage::updateIntrinsicSizeIfNeeded(const IntSize& newSize, bool imageSizeChanged)
    179179{
    180180    if (newSize == intrinsicSize() && !imageSizeChanged)
     
    417417void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect)
    418418{
    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());
    423424    if (!img || img->isNull())
    424425        return;
     
    427428    CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator() : CompositeSourceOver;
    428429    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);
    431432}
    432433
     
    526527            containerSize = cachedImage->image()->size();
    527528            // 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()));
    530531        }
    531532    }
  • trunk/Source/WebCore/rendering/RenderImage.h

    r105513 r111515  
    9595    IntSize imageSizeForError(CachedImage*) const;
    9696    void imageDimensionsChanged(bool imageSizeChanged, const IntRect* = 0);
    97     bool updateIntrinsicSizeIfNeeded(const LayoutSize&, bool imageSizeChanged);
     97    bool updateIntrinsicSizeIfNeeded(const IntSize&, bool imageSizeChanged);
    9898
    9999    void paintAreaElementFocusRing(PaintInfo&);
  • trunk/Source/WebCore/rendering/RenderVideo.cpp

    r110218 r111515  
    167167        elementSize = intrinsicSize();
    168168
    169     IntRect contentRect = contentBoxRect();
     169    IntRect contentRect = pixelSnappedIntRect(contentBoxRect());
    170170    if (elementSize.isEmpty() || contentRect.isEmpty())
    171171        return IntRect();
     
    226226        paintIntoRect(paintInfo.context, rect);
    227227    else if (document()->view() && document()->view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers)
    228         mediaPlayer->paintCurrentFrameInContext(paintInfo.context, rect);
     228        mediaPlayer->paintCurrentFrameInContext(paintInfo.context, pixelSnappedIntRect(rect));
    229229    else
    230         mediaPlayer->paint(paintInfo.context, rect);
     230        mediaPlayer->paint(paintInfo.context, pixelSnappedIntRect(rect));
    231231}
    232232
  • trunk/Source/WebCore/rendering/RenderWidget.cpp

    r110323 r111515  
    141141}
    142142
    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.
     146static inline IntRect roundedIntRect(const LayoutRect& rect)
     147{
     148    return IntRect(roundedIntPoint(rect.location()), roundedIntSize(rect.size()));
     149}
     150
     151bool RenderWidget::setWidgetGeometry(const LayoutRect& frame)
    144152{
    145153    if (!node())
    146154        return false;
    147155
    148     IntRect clipRect = enclosingLayer()->childrenClipRect();
     156    IntRect clipRect = roundedIntRect(enclosingLayer()->childrenClipRect());
    149157    bool clipChanged = m_clipRect != clipRect;
    150158    bool boundsChanged = m_widget->frameRect() != frame;
     
    157165    RenderWidgetProtector protector(this);
    158166    RefPtr<Node> protectedNode(node());
    159     m_widget->setFrameRect(frame);
     167    m_widget->setFrameRect(roundedIntRect(frame));
    160168   
    161169#if USE(ACCELERATED_COMPOSITING)
     
    169177bool RenderWidget::updateWidgetGeometry()
    170178{
    171     IntRect contentBox = contentBoxRect();
     179    LayoutRect contentBox = contentBoxRect();
    172180    if (!m_widget->transformsAffectFrameRect())
    173181        return setWidgetGeometry(absoluteContentBox());
    174182
    175     IntRect absoluteContentBox = IntRect(localToAbsoluteQuad(FloatQuad(contentBox)).boundingBox());
     183    LayoutRect absoluteContentBox(localToAbsoluteQuad(FloatQuad(contentBox)).boundingBox());
    176184    if (m_widget->isFrameView()) {
    177185        contentBox.setLocation(absoluteContentBox.location());
     
    277285        // Tell the widget to paint now.  This is the only time the widget is allowed
    278286        // 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;
    284293        // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
    285294        // 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  
    7171    virtual void setOverlapTestResult(bool);
    7272
    73     bool setWidgetGeometry(const IntRect&);
     73    bool setWidgetGeometry(const LayoutRect&);
    7474    bool updateWidgetGeometry();
    7575
Note: See TracChangeset for help on using the changeset viewer.