Title: [111515] trunk/Source/WebCore
Revision
111515
Author
[email protected]
Date
2012-03-21 02:32:01 -0700 (Wed, 21 Mar 2012)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (111514 => 111515)


--- trunk/Source/WebCore/ChangeLog	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/ChangeLog	2012-03-21 09:32:01 UTC (rev 111515)
@@ -1,3 +1,56 @@
+2012-03-21  Levi Weintraub  <[email protected]>
+
+        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):
+
 2012-03-21  Ilya Tikhonovsky  <[email protected]>
 
         Web Inspector: HeapProfiler: support distance column in Summary View.

Modified: trunk/Source/WebCore/rendering/RenderFrameBase.cpp (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderFrameBase.cpp	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderFrameBase.cpp	2012-03-21 09:32:01 UTC (rev 111515)
@@ -78,9 +78,9 @@
 
     // expand the frame by setting frame height = content height
     if (isScrollable || !fixedHeight || childRoot->isFrameSet())
-        setHeight(max(height(), childFrameView->contentsHeight() + vBorder));
+        setHeight(max<LayoutUnit>(height(), childFrameView->contentsHeight() + vBorder));
     if (isScrollable || !fixedWidth || childRoot->isFrameSet())
-        setWidth(max(width(), childFrameView->contentsWidth() + hBorder));
+        setWidth(max<LayoutUnit>(width(), childFrameView->contentsWidth() + hBorder));
 
     updateWidgetPosition();
 

Modified: trunk/Source/WebCore/rendering/RenderFullScreen.cpp (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderFullScreen.cpp	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderFullScreen.cpp	2012-03-21 09:32:01 UTC (rev 111515)
@@ -140,7 +140,7 @@
     m_placeholder = placeholder;
 }
 
-void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const IntRect& frameRect)
+void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const LayoutRect& frameRect)
 {
     if (style->width().isAuto())
         style->setWidth(Length(frameRect.width(), Fixed));

Modified: trunk/Source/WebCore/rendering/RenderFullScreen.h (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderFullScreen.h	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderFullScreen.h	2012-03-21 09:32:01 UTC (rev 111515)
@@ -39,7 +39,7 @@
 
     void setPlaceholder(RenderBlock*);
     RenderBlock* placeholder() { return m_placeholder; }
-    void createPlaceholder(PassRefPtr<RenderStyle>, const IntRect& frameRect);
+    void createPlaceholder(PassRefPtr<RenderStyle>, const LayoutRect& frameRect);
 
 
     static RenderObject* wrapRenderer(RenderObject* renderer, Document*);

Modified: trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderHTMLCanvas.cpp	2012-03-21 09:32:01 UTC (rev 111515)
@@ -88,7 +88,7 @@
     if (!preferredLogicalWidthsDirty())
         setPreferredLogicalWidthsDirty(true);
 
-    IntSize oldSize = size();
+    LayoutSize oldSize = size();
     computeLogicalWidth();
     computeLogicalHeight();
     if (oldSize == size())

Modified: trunk/Source/WebCore/rendering/RenderIFrame.cpp (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderIFrame.cpp	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderIFrame.cpp	2012-03-21 09:32:01 UTC (rev 111515)
@@ -57,7 +57,7 @@
         if (!view)
             return;
         int border = borderTop() + borderBottom();
-        setHeight(max(height(), view->contentsHeight() + border));
+        setHeight(max<LayoutUnit>(height(), view->contentsHeight() + border));
     }
 }
 
@@ -75,7 +75,7 @@
         if (!view)
             return;
         LayoutUnit border = borderLeft() + borderRight();
-        setWidth(max(width(), view->contentsWidth() + border));
+        setWidth(max<LayoutUnit>(width(), view->contentsWidth() + border));
     }
 }
 

Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderImage.cpp	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp	2012-03-21 09:32:01 UTC (rev 111515)
@@ -175,7 +175,7 @@
     imageDimensionsChanged(imageSizeChanged, rect);
 }
 
-bool RenderImage::updateIntrinsicSizeIfNeeded(const LayoutSize& newSize, bool imageSizeChanged)
+bool RenderImage::updateIntrinsicSizeIfNeeded(const IntSize& newSize, bool imageSizeChanged)
 {
     if (newSize == intrinsicSize() && !imageSizeChanged)
         return false;
@@ -416,18 +416,19 @@
 
 void RenderImage::paintIntoRect(GraphicsContext* context, const LayoutRect& rect)
 {
-    if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || rect.width() <= 0 || rect.height() <= 0)
+    IntRect alignedRect = pixelSnappedIntRect(rect);
+    if (!m_imageResource->hasImage() || m_imageResource->errorOccurred() || alignedRect.width() <= 0 || alignedRect.height() <= 0)
         return;
 
-    RefPtr<Image> img = m_imageResource->image(rect.width(), rect.height());
+    RefPtr<Image> img = m_imageResource->image(alignedRect.width(), alignedRect.height());
     if (!img || img->isNull())
         return;
 
     HTMLImageElement* imageElt = (node() && node()->hasTagName(imgTag)) ? static_cast<HTMLImageElement*>(node()) : 0;
     CompositeOperator compositeOperator = imageElt ? imageElt->compositeOperator() : CompositeSourceOver;
     Image* image = m_imageResource->image().get();
-    bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, rect.size());
-    context->drawImage(m_imageResource->image(rect.width(), rect.height()).get(), style()->colorSpace(), rect, compositeOperator, useLowQualityScaling);
+    bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, image, alignedRect.size());
+    context->drawImage(m_imageResource->image(alignedRect.width(), alignedRect.height()).get(), style()->colorSpace(), alignedRect, compositeOperator, useLowQualityScaling);
 }
 
 bool RenderImage::backgroundIsObscured() const
@@ -525,8 +526,8 @@
         if (cachedImage && cachedImage->image()) {
             containerSize = cachedImage->image()->size();
             // FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
-            containerSize.setWidth(static_cast<LayoutUnit>(containerSize.width() * style()->effectiveZoom()));
-            containerSize.setHeight(static_cast<LayoutUnit>(containerSize.height() * style()->effectiveZoom()));
+            containerSize.setWidth(roundToInt(containerSize.width() * style()->effectiveZoom()));
+            containerSize.setHeight(roundToInt(containerSize.height() * style()->effectiveZoom()));
         }
     }
 

Modified: trunk/Source/WebCore/rendering/RenderImage.h (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderImage.h	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderImage.h	2012-03-21 09:32:01 UTC (rev 111515)
@@ -94,7 +94,7 @@
 
     IntSize imageSizeForError(CachedImage*) const;
     void imageDimensionsChanged(bool imageSizeChanged, const IntRect* = 0);
-    bool updateIntrinsicSizeIfNeeded(const LayoutSize&, bool imageSizeChanged);
+    bool updateIntrinsicSizeIfNeeded(const IntSize&, bool imageSizeChanged);
 
     void paintAreaElementFocusRing(PaintInfo&);
 

Modified: trunk/Source/WebCore/rendering/RenderVideo.cpp (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderVideo.cpp	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderVideo.cpp	2012-03-21 09:32:01 UTC (rev 111515)
@@ -166,7 +166,7 @@
     else
         elementSize = intrinsicSize();
 
-    IntRect contentRect = contentBoxRect();
+    IntRect contentRect = pixelSnappedIntRect(contentBoxRect());
     if (elementSize.isEmpty() || contentRect.isEmpty())
         return IntRect();
 
@@ -225,9 +225,9 @@
     if (displayingPoster)
         paintIntoRect(paintInfo.context, rect);
     else if (document()->view() && document()->view()->paintBehavior() & PaintBehaviorFlattenCompositingLayers)
-        mediaPlayer->paintCurrentFrameInContext(paintInfo.context, rect);
+        mediaPlayer->paintCurrentFrameInContext(paintInfo.context, pixelSnappedIntRect(rect));
     else
-        mediaPlayer->paint(paintInfo.context, rect);
+        mediaPlayer->paint(paintInfo.context, pixelSnappedIntRect(rect));
 }
 
 void RenderVideo::layout()

Modified: trunk/Source/WebCore/rendering/RenderWidget.cpp (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderWidget.cpp	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderWidget.cpp	2012-03-21 09:32:01 UTC (rev 111515)
@@ -140,12 +140,20 @@
     clearWidget();
 }
 
-bool RenderWidget::setWidgetGeometry(const IntRect& frame)
+// Widgets are always placed on integer boundaries, so rounding the size is actually
+// the desired behavior. This function is here because it's otherwise seldom what we
+// want to do with a LayoutRect.
+static inline IntRect roundedIntRect(const LayoutRect& rect)
 {
+    return IntRect(roundedIntPoint(rect.location()), roundedIntSize(rect.size()));
+}
+
+bool RenderWidget::setWidgetGeometry(const LayoutRect& frame)
+{
     if (!node())
         return false;
 
-    IntRect clipRect = enclosingLayer()->childrenClipRect();
+    IntRect clipRect = roundedIntRect(enclosingLayer()->childrenClipRect());
     bool clipChanged = m_clipRect != clipRect;
     bool boundsChanged = m_widget->frameRect() != frame;
 
@@ -156,7 +164,7 @@
 
     RenderWidgetProtector protector(this);
     RefPtr<Node> protectedNode(node());
-    m_widget->setFrameRect(frame);
+    m_widget->setFrameRect(roundedIntRect(frame));
     
 #if USE(ACCELERATED_COMPOSITING)
     if (hasLayer() && layer()->isComposited())
@@ -168,11 +176,11 @@
 
 bool RenderWidget::updateWidgetGeometry()
 {
-    IntRect contentBox = contentBoxRect();
+    LayoutRect contentBox = contentBoxRect();
     if (!m_widget->transformsAffectFrameRect())
         return setWidgetGeometry(absoluteContentBox());
 
-    IntRect absoluteContentBox = IntRect(localToAbsoluteQuad(FloatQuad(contentBox)).boundingBox());
+    LayoutRect absoluteContentBox(localToAbsoluteQuad(FloatQuad(contentBox)).boundingBox());
     if (m_widget->isFrameView()) {
         contentBox.setLocation(absoluteContentBox.location());
         return setWidgetGeometry(contentBox);
@@ -276,11 +284,12 @@
     if (m_widget) {
         // Tell the widget to paint now.  This is the only time the widget is allowed
         // to paint itself.  That way it will composite properly with z-indexed layers.
-        LayoutPoint widgetLocation = m_widget->frameRect().location();
-        LayoutPoint paintLocation(adjustedPaintOffset.x() + borderLeft() + paddingLeft(), adjustedPaintOffset.y() + borderTop() + paddingTop());
-        LayoutRect paintRect = paintInfo.rect;
+        IntPoint widgetLocation = m_widget->frameRect().location();
+        IntPoint paintLocation(roundToInt(adjustedPaintOffset.x() + borderLeft() + paddingLeft()),
+            roundToInt(adjustedPaintOffset.y() + borderTop() + paddingTop()));
+        IntRect paintRect = paintInfo.rect;
 
-        LayoutSize widgetPaintOffset = paintLocation - widgetLocation;
+        IntSize widgetPaintOffset = paintLocation - widgetLocation;
         // When painting widgets into compositing layers, tx and ty are relative to the enclosing compositing layer,
         // not the root. In this case, shift the CTM and adjust the paintRect to be root-relative to fix plug-in drawing.
         if (!widgetPaintOffset.isZero()) {

Modified: trunk/Source/WebCore/rendering/RenderWidget.h (111514 => 111515)


--- trunk/Source/WebCore/rendering/RenderWidget.h	2012-03-21 09:24:39 UTC (rev 111514)
+++ trunk/Source/WebCore/rendering/RenderWidget.h	2012-03-21 09:32:01 UTC (rev 111515)
@@ -70,7 +70,7 @@
     virtual void setSelectionState(SelectionState);
     virtual void setOverlapTestResult(bool);
 
-    bool setWidgetGeometry(const IntRect&);
+    bool setWidgetGeometry(const LayoutRect&);
     bool updateWidgetGeometry();
 
     RefPtr<Widget> m_widget;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to