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


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@111515 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderImage.cpp b/Source/WebCore/rendering/RenderImage.cpp
index 6406f6f..4d588b9 100644
--- a/Source/WebCore/rendering/RenderImage.cpp
+++ b/Source/WebCore/rendering/RenderImage.cpp
@@ -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()));
         }
     }