Bug 1450134. Replace ToRelativeLayoutRect() with ToRoundedLayoutRect(). r=kats draft
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Thu, 29 Mar 2018 17:57:43 -0400
changeset 775118 c59b1535590dcbb6c49e6b426297825af36b0c01
parent 774966 a9d82013457d1d246244707a6e0d7d57e34b530c
push id104616
push userbmo:jmuizelaar@mozilla.com
push dateFri, 30 Mar 2018 03:45:58 +0000
reviewerskats
bugs1450134
milestone61.0a1
Bug 1450134. Replace ToRelativeLayoutRect() with ToRoundedLayoutRect(). r=kats This function doesn't use any StackingContextHelper state anymore. We should make what it does clearer and move it to a better place.
gfx/layers/wr/ScrollingLayersHelper.cpp
gfx/layers/wr/StackingContextHelper.cpp
gfx/layers/wr/StackingContextHelper.h
gfx/layers/wr/WebRenderCommandBuilder.cpp
gfx/layers/wr/WebRenderUserData.cpp
gfx/webrender_bindings/WebRenderTypes.h
layout/forms/nsButtonFrameRenderer.cpp
layout/generic/TextDrawTarget.h
layout/generic/nsBulletFrame.cpp
layout/generic/nsCanvasFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsHTMLCanvasFrame.cpp
layout/ipc/RenderFrameParent.cpp
layout/painting/DisplayItemClip.cpp
layout/painting/nsCSSRenderingBorders.cpp
layout/painting/nsDisplayList.cpp
layout/painting/nsImageRenderer.cpp
layout/tables/nsTableFrame.cpp
layout/xul/nsImageBoxFrame.cpp
widget/cocoa/nsNativeThemeCocoa.mm
widget/gtk/nsNativeThemeGTK.cpp
--- a/gfx/layers/wr/ScrollingLayersHelper.cpp
+++ b/gfx/layers/wr/ScrollingLayersHelper.cpp
@@ -344,17 +344,17 @@ ScrollingLayersHelper::RecurseAndDefineC
   LayoutDeviceRect clip = LayoutDeviceRect::FromAppUnits(
       aChain->mClip.GetClipRect(), aAppUnitsPerDevPixel);
   nsTArray<wr::ComplexClipRegion> wrRoundedRects;
   aChain->mClip.ToComplexClipRegions(aAppUnitsPerDevPixel, aSc, wrRoundedRects);
 
   // Define the clip
   wr::WrClipId clipId = mBuilder->DefineClip(
       ancestorIds.first, ancestorIds.second,
-      aSc.ToRelativeLayoutRect(clip), &wrRoundedRects);
+      wr::ToRoundedLayoutRect(clip), &wrRoundedRects);
   if (!mBuilder->HasExtraClip()) {
     mCacheStack.back()[aChain] = clipId;
   }
 
   ids.second = Some(clipId);
   return ids;
 }
 
@@ -451,18 +451,18 @@ ScrollingLayersHelper::RecurseAndDefineA
   // uses this to clamp the scroll position, we don't need to send this to
   // WebRender at all. Instead, we take the position from the composition
   // bounds.
   contentRect.MoveTo(clipBounds.TopLeft());
 
   auto scrollId = mBuilder->DefineScrollLayer(viewId,
       ancestorIds.first,
       ancestorIds.second,
-      aSc.ToRelativeLayoutRect(contentRect),
-      aSc.ToRelativeLayoutRect(clipBounds));
+      wr::ToRoundedLayoutRect(contentRect),
+      wr::ToRoundedLayoutRect(clipBounds));
 
   ids.first = Some(scrollId);
   return ids;
 }
 
 const DisplayItemClipChain*
 ScrollingLayersHelper::ExtendChain(const DisplayItemClipChain* aClip)
 {
--- a/gfx/layers/wr/StackingContextHelper.cpp
+++ b/gfx/layers/wr/StackingContextHelper.cpp
@@ -61,24 +61,16 @@ StackingContextHelper::StackingContextHe
 
 StackingContextHelper::~StackingContextHelper()
 {
   if (mBuilder) {
     mBuilder->PopStackingContext();
   }
 }
 
-wr::LayoutRect
-StackingContextHelper::ToRelativeLayoutRect(const LayoutDeviceRect& aRect) const
-{
-  auto rect = aRect;
-  rect.Round();
-  return wr::ToLayoutRect(rect);
-}
-
 const Maybe<gfx::Matrix4x4>&
 StackingContextHelper::GetTransformForScrollData() const
 {
   return mTransformForScrollData;
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/wr/StackingContextHelper.h
+++ b/gfx/layers/wr/StackingContextHelper.h
@@ -44,28 +44,16 @@ public:
   // of the tree, so that we have a StackingContextHelper to pass down into
   // the RenderLayer traversal, but don't actually want it to push a stacking
   // context on the display list builder.
   StackingContextHelper();
 
   // Pops the stacking context, if one was pushed during the constructor.
   ~StackingContextHelper();
 
-  // When this StackingContextHelper is in scope, this function can be used
-  // to convert a rect from the layer system's coordinate space to a LayoutRect
-  // that is relative to the stacking context. This is useful because most
-  // things that are pushed inside the stacking context need to be relative
-  // to the stacking context.
-  // We allow passing in a LayoutDeviceRect for convenience because in a lot of
-  // cases with WebRender display item generate the layout device space is the
-  // same as the layer space. (TODO: try to make this more explicit somehow).
-  // We also round the rectangle to ints after transforming since the output
-  // is the final destination rect.
-  wr::LayoutRect ToRelativeLayoutRect(const LayoutDeviceRect& aRect) const;
-
   // Export the inherited scale
   gfx::Size GetInheritedScale() const { return mScale; }
 
   const gfx::Matrix& GetInheritedTransform() const
   {
     return mInheritedTransform;
   }
 
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -1406,17 +1406,17 @@ WebRenderCommandBuilder::PushImage(nsDis
     // Async ImageContainer does not create ImageKey, instead it uses Pipeline.
     MOZ_ASSERT(key.isNothing());
     return true;
   }
   if (!key) {
     return false;
   }
 
-  auto r = aSc.ToRelativeLayoutRect(aRect);
+  auto r = wr::ToRoundedLayoutRect(aRect);
   gfx::SamplingFilter sampleFilter = nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame());
   aBuilder.PushImage(r, r, !aItem->BackfaceIsHidden(), wr::ToImageRendering(sampleFilter), key.value());
 
   return true;
 }
 
 static bool
 PaintByLayer(nsDisplayItem* aItem,
@@ -1759,17 +1759,17 @@ WebRenderCommandBuilder::BuildWrMaskImag
                                                                     aSc, aDisplayListBuilder,
                                                                     imageRect);
   if (!fallbackData) {
     return Nothing();
   }
 
   wr::WrImageMask imageMask;
   imageMask.image = fallbackData->GetKey().value();
-  imageMask.rect = aSc.ToRelativeLayoutRect(aBounds);
+  imageMask.rect = wr::ToRoundedLayoutRect(aBounds);
   imageMask.repeat = false;
   return Some(imageMask);
 }
 
 bool
 WebRenderCommandBuilder::PushItemAsImage(nsDisplayItem* aItem,
                                          wr::DisplayListBuilder& aBuilder,
                                          wr::IpcResourceUpdateQueue& aResources,
@@ -1779,17 +1779,17 @@ WebRenderCommandBuilder::PushItemAsImage
   LayoutDeviceRect imageRect;
   RefPtr<WebRenderFallbackData> fallbackData = GenerateFallbackData(aItem, aBuilder, aResources,
                                                                     aSc, aDisplayListBuilder,
                                                                     imageRect);
   if (!fallbackData) {
     return false;
   }
 
-  wr::LayoutRect dest = aSc.ToRelativeLayoutRect(imageRect);
+  wr::LayoutRect dest = wr::ToRoundedLayoutRect(imageRect);
   gfx::SamplingFilter sampleFilter = nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame());
   aBuilder.PushImage(dest,
                      dest,
                      !aItem->BackfaceIsHidden(),
                      wr::ToImageRendering(sampleFilter),
                      fallbackData->GetKey().value());
   return true;
 }
--- a/gfx/layers/wr/WebRenderUserData.cpp
+++ b/gfx/layers/wr/WebRenderUserData.cpp
@@ -226,17 +226,17 @@ WebRenderImageData::CreateAsyncImageWebR
   // Push IFrame for async image pipeline.
   //
   // We don't push a stacking context for this async image pipeline here.
   // Instead, we do it inside the iframe that hosts the image. As a result,
   // a bunch of the calculations normally done as part of that stacking
   // context need to be done manually and pushed over to the parent side,
   // where it will be done when we build the display list for the iframe.
   // That happens in AsyncImagePipelineManager.
-  wr::LayoutRect r = aSc.ToRelativeLayoutRect(aBounds);
+  wr::LayoutRect r = wr::ToRoundedLayoutRect(aBounds);
   aBuilder.PushIFrame(r, aIsBackfaceVisible, mPipelineId.ref());
 
   WrBridge()->AddWebRenderParentCommand(OpUpdateAsyncImagePipeline(mPipelineId.value(),
                                                                    aSCBounds,
                                                                    aSCTransform,
                                                                    aScaleToSize,
                                                                    aFilter,
                                                                    aMixBlendMode));
--- a/gfx/webrender_bindings/WebRenderTypes.h
+++ b/gfx/webrender_bindings/WebRenderTypes.h
@@ -344,16 +344,22 @@ static inline wr::DeviceUintRect ToDevic
   return r;
 }
 
 static inline wr::LayoutRect ToLayoutRect(const mozilla::LayoutDeviceIntRect& rect)
 {
   return ToLayoutRect(IntRectToRect(rect));
 }
 
+static inline wr::LayoutRect ToRoundedLayoutRect(const mozilla::LayoutDeviceRect& aRect) {
+  auto rect = aRect;
+  rect.Round();
+  return wr::ToLayoutRect(rect);
+}
+
 static inline wr::LayoutSize ToLayoutSize(const mozilla::LayoutDeviceSize& size)
 {
   wr::LayoutSize ls;
   ls.width = size.width;
   ls.height = size.height;
   return ls;
 }
 
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -148,21 +148,21 @@ nsDisplayButtonBoxShadowOuter::CreateWeb
 {
   if (!CanBuildWebRenderDisplayItems()) {
     return false;
   }
   int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
   nsRect shadowRect = nsRect(ToReferenceFrame(), mFrame->GetSize());
   LayoutDeviceRect deviceBox =
     LayoutDeviceRect::FromAppUnits(shadowRect, appUnitsPerDevPixel);
-  wr::LayoutRect deviceBoxRect = aSc.ToRelativeLayoutRect(deviceBox);
+  wr::LayoutRect deviceBoxRect = wr::ToRoundedLayoutRect(deviceBox);
 
   LayoutDeviceRect clipRect =
     LayoutDeviceRect::FromAppUnits(mVisibleRect, appUnitsPerDevPixel);
-  wr::LayoutRect deviceClipRect = aSc.ToRelativeLayoutRect(clipRect);
+  wr::LayoutRect deviceClipRect = wr::ToRoundedLayoutRect(clipRect);
 
   bool hasBorderRadius;
   Unused << nsCSSRendering::HasBoxShadowNativeTheme(mFrame, hasBorderRadius);
 
   LayoutDeviceSize zeroSize;
   wr::BorderRadius borderRadius = wr::ToBorderRadius(zeroSize, zeroSize,
                                                      zeroSize, zeroSize);
   if (hasBorderRadius) {
--- a/layout/generic/TextDrawTarget.h
+++ b/layout/generic/TextDrawTarget.h
@@ -58,17 +58,17 @@ public:
   {
     SetPermitSubpixelAA(!aItem->IsSubpixelAADisabled());
 
     // Compute clip/bounds
     auto appUnitsPerDevPixel = aItem->Frame()->PresContext()->AppUnitsPerDevPixel();
     LayoutDeviceRect layoutBoundsRect = LayoutDeviceRect::FromAppUnits(
         aBounds, appUnitsPerDevPixel);
     LayoutDeviceRect layoutClipRect = layoutBoundsRect;
-    mBoundsRect = aSc.ToRelativeLayoutRect(layoutBoundsRect);
+    mBoundsRect = wr::ToRoundedLayoutRect(layoutBoundsRect);
 
     // Add 1 pixel of dirty area around clip rect to allow us to paint
     // antialiased pixels beyond the measured text extents.
     layoutClipRect.Inflate(1);
     mClipStack.AppendElement(layoutClipRect);
 
     mBackfaceVisible = !aItem->BackfaceIsHidden();
 
@@ -241,17 +241,17 @@ public:
       pos.x -= aThickness / 2; // adjust from center to corner
       size = LayoutDeviceSize(aThickness, aEnd.y - aStart.y);
     } else {
       pos.y -= aThickness / 2; // adjust from center to corner
       size = LayoutDeviceSize(aEnd.x - aStart.x, aThickness);
     }
 
     wr::Line decoration;
-    decoration.bounds = mSc.ToRelativeLayoutRect(LayoutDeviceRect(pos, size));
+    decoration.bounds = wr::ToRoundedLayoutRect(LayoutDeviceRect(pos, size));
     decoration.wavyLineThickness = 0; // dummy value, unused
     decoration.color = wr::ToColorF(aColor);
     decoration.orientation = aVertical
       ? wr::LineOrientation::Vertical
       : wr::LineOrientation::Horizontal;
 
     switch (aStyle) {
       case NS_STYLE_TEXT_DECORATION_STYLE_SOLID:
@@ -280,32 +280,32 @@ public:
   void
   AppendWavyDecoration(const Rect& aBounds,
                        const float aThickness,
                        const bool aVertical,
                        const Color& aColor)
   {
     wr::Line decoration;
 
-    decoration.bounds = mSc.ToRelativeLayoutRect(
+    decoration.bounds = wr::ToRoundedLayoutRect(
       LayoutDeviceRect::FromUnknownRect(aBounds));
     decoration.wavyLineThickness = aThickness;
     decoration.color = wr::ToColorF(aColor);
     decoration.orientation = aVertical
       ? wr::LineOrientation::Vertical
       : wr::LineOrientation::Horizontal;
     decoration.style = wr::LineStyle::Wavy;
 
     mBuilder.PushLine(ClipRect(), mBackfaceVisible, decoration);
   }
 
 private:
   wr::LayerRect ClipRect()
   {
-    return mSc.ToRelativeLayoutRect(mClipStack.LastElement());
+    return wr::ToRoundedLayoutRect(mClipStack.LastElement());
   }
   // Whether anything unsupported was encountered. Currently:
   //
   // * Synthetic bold/italics
   // * SVG fonts
   // * Unserializable fonts
   // * Tofu glyphs
   // * Pratial ligatures
@@ -400,17 +400,17 @@ public:
     MOZ_CRASH("TextDrawTarget: Method shouldn't be called");
   }
 
   void FillRect(const Rect &aRect,
                 const Pattern &aPattern,
                 const DrawOptions &aOptions = DrawOptions()) override {
     MOZ_RELEASE_ASSERT(aPattern.GetType() == PatternType::COLOR);
 
-    auto rect = mSc.ToRelativeLayoutRect(LayoutDeviceRect::FromUnknownRect(aRect));
+    auto rect = wr::ToRoundedLayoutRect(LayoutDeviceRect::FromUnknownRect(aRect));
     auto color = wr::ToColorF(static_cast<const ColorPattern&>(aPattern).mColor);
     mBuilder.PushRect(rect, ClipRect(), mBackfaceVisible, color);
   }
 
   void StrokeRect(const Rect &aRect,
                   const Pattern &aPattern,
                   const StrokeOptions &aStrokeOptions,
                   const DrawOptions &aOptions) override {
@@ -420,35 +420,35 @@ public:
     wr::Line line;
     line.wavyLineThickness = 0; // dummy value, unused
     line.color = wr::ToColorF(static_cast<const ColorPattern&>(aPattern).mColor);
     line.style = wr::LineStyle::Solid;
 
     // Top horizontal line
     LayoutDevicePoint top(aRect.x, aRect.y - aStrokeOptions.mLineWidth / 2);
     LayoutDeviceSize horiSize(aRect.width, aStrokeOptions.mLineWidth);
-    line.bounds = mSc.ToRelativeLayoutRect(LayoutDeviceRect(top, horiSize));
+    line.bounds = wr::ToRoundedLayoutRect(LayoutDeviceRect(top, horiSize));
     line.orientation = wr::LineOrientation::Horizontal;
     mBuilder.PushLine(ClipRect(), mBackfaceVisible, line);
 
     // Bottom horizontal line
     LayoutDevicePoint bottom(aRect.x, aRect.YMost() - aStrokeOptions.mLineWidth / 2);
-    line.bounds = mSc.ToRelativeLayoutRect(LayoutDeviceRect(bottom, horiSize));
+    line.bounds = wr::ToRoundedLayoutRect(LayoutDeviceRect(bottom, horiSize));
     mBuilder.PushLine(ClipRect(), mBackfaceVisible, line);
 
     // Left vertical line
     LayoutDevicePoint left(aRect.x + aStrokeOptions.mLineWidth / 2, aRect.y + aStrokeOptions.mLineWidth / 2);
     LayoutDeviceSize vertSize(aStrokeOptions.mLineWidth, aRect.height - aStrokeOptions.mLineWidth);
-    line.bounds = mSc.ToRelativeLayoutRect(LayoutDeviceRect(left, vertSize));
+    line.bounds = wr::ToRoundedLayoutRect(LayoutDeviceRect(left, vertSize));
     line.orientation = wr::LineOrientation::Vertical;
     mBuilder.PushLine(ClipRect(), mBackfaceVisible, line);
 
     // Right vertical line
     LayoutDevicePoint right(aRect.XMost() - aStrokeOptions.mLineWidth / 2, aRect.y + aStrokeOptions.mLineWidth / 2);
-    line.bounds = mSc.ToRelativeLayoutRect(LayoutDeviceRect(right, vertSize));
+    line.bounds = wr::ToRoundedLayoutRect(LayoutDeviceRect(right, vertSize));
     mBuilder.PushLine(ClipRect(), mBackfaceVisible, line);
   }
 
   void StrokeLine(const Point &aStart,
                   const Point &aEnd,
                   const Pattern &aPattern,
                   const StrokeOptions &aStrokeOptions,
                   const DrawOptions &aOptions) override {
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -520,17 +520,17 @@ BulletRenderer::CreateWebRenderCommandsF
 
   gfx::IntSize size;
   Maybe<wr::ImageKey> key = aManager->CommandBuilder().CreateImageKey(aItem, container, aBuilder, aResources,
                                                                       aSc, size, Nothing());
   if (key.isNothing()) {
     return true;  // Nothing to do
   }
 
-  wr::LayoutRect dest = aSc.ToRelativeLayoutRect(destRect);
+  wr::LayoutRect dest = wr::ToRoundedLayoutRect(destRect);
 
   aBuilder.PushImage(dest,
                      dest,
                      !aItem->BackfaceIsHidden(),
                      wr::ImageRendering::Auto,
                      key.value());
 
   return true;
@@ -540,17 +540,17 @@ bool
 BulletRenderer::CreateWebRenderCommandsForPath(nsDisplayItem* aItem,
                                                wr::DisplayListBuilder& aBuilder,
                                                wr::IpcResourceUpdateQueue& aResources,
                                                const layers::StackingContextHelper& aSc,
                                                mozilla::layers::WebRenderLayerManager* aManager,
                                                nsDisplayListBuilder* aDisplayListBuilder)
 {
   MOZ_ASSERT(IsPathType());
-  wr::LayoutRect dest = aSc.ToRelativeLayoutRect(mPathRect);
+  wr::LayoutRect dest = wr::ToRoundedLayoutRect(mPathRect);
   auto color = wr::ToColorF(ToDeviceColor(mColor));
   bool isBackfaceVisible = !aItem->BackfaceIsHidden();
   switch (mListStyleType) {
     case NS_STYLE_LIST_STYLE_CIRCLE: {
       LayoutDeviceSize radii = mPathRect.Size() / 2.0;
       auto borderWidths = wr::ToBorderWidths(1.0, 1.0, 1.0, 1.0);
       wr::BorderSide side = { color, wr::BorderStyle::Solid };
       wr::BorderSide sides[4] = { side, side, side, side };
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -322,19 +322,19 @@ nsDisplayCanvasBackgroundColor::CreateWe
   nsCanvasFrame *frame = static_cast<nsCanvasFrame *>(mFrame);
   nsPoint offset = ToReferenceFrame();
   nsRect bgClipRect = frame->CanvasArea() + offset;
   int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
 
   LayoutDeviceRect rect = LayoutDeviceRect::FromAppUnits(
           bgClipRect, appUnitsPerDevPixel);
 
-  wr::LayoutRect transformedRect = aSc.ToRelativeLayoutRect(rect);
-  aBuilder.PushRect(transformedRect,
-                    transformedRect,
+  wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(rect);
+  aBuilder.PushRect(roundedRect,
+                    roundedRect,
                     !BackfaceIsHidden(),
                     wr::ToColorF(ToDeviceColor(mColor)));
   return true;
 }
 
 #ifdef MOZ_DUMP_PAINTING
 void
 nsDisplayCanvasBackgroundColor::WriteDebugInfo(std::stringstream& aStream)
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2241,17 +2241,17 @@ void nsDisplaySelectionOverlay::Paint(ns
 
 bool
 nsDisplaySelectionOverlay::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
                                                   mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                   const StackingContextHelper& aSc,
                                                   mozilla::layers::WebRenderLayerManager* aManager,
                                                   nsDisplayListBuilder* aDisplayListBuilder)
 {
-  wr::LayoutRect bounds = aSc.ToRelativeLayoutRect(
+  wr::LayoutRect bounds = wr::ToRoundedLayoutRect(
     LayoutDeviceRect::FromAppUnits(nsRect(ToReferenceFrame(), Frame()->GetSize()),
                                    mFrame->PresContext()->AppUnitsPerDevPixel()));
   aBuilder.PushRect(bounds, bounds, !BackfaceIsHidden(),
                     wr::ToColorF(ComputeColor()));
   return true;
 }
 
 static Element*
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -168,17 +168,17 @@ public:
 
         // We don't push a stacking context for this async image pipeline here.
         // Instead, we do it inside the iframe that hosts the image. As a result,
         // a bunch of the calculations normally done as part of that stacking
         // context need to be done manually and pushed over to the parent side,
         // where it will be done when we build the display list for the iframe.
         // That happens in WebRenderCompositableHolder.
 
-        wr::LayoutRect r = aSc.ToRelativeLayoutRect(bounds);
+        wr::LayoutRect r = wr::ToRoundedLayoutRect(bounds);
         aBuilder.PushIFrame(r, !BackfaceIsHidden(), data->GetPipelineId().ref());
 
         gfx::Matrix4x4 scTransform;
         gfxRect destGFXRect = mFrame->PresContext()->AppUnitsToGfxUnits(dest);
         scTransform.PreScale(destGFXRect.Width() / canvasSizeInPx.width,
                              destGFXRect.Height() / canvasSizeInPx.height, 1.0f);
         if (data->NeedsYFlip()) {
           scTransform = scTransform.PreTranslate(0, data->GetSize().height, 0).PreScale(1, -1, 1);
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -386,17 +386,17 @@ nsDisplayRemote::CreateWebRenderCommands
                                          nsDisplayListBuilder* aDisplayListBuilder)
 {
   mOffset = mozilla::layout::GetContentRectLayerOffset(mFrame, aDisplayListBuilder);
 
   mozilla::LayoutDeviceRect rect = mozilla::LayoutDeviceRect::FromAppUnits(
     mFrame->GetContentRectRelativeToSelf(), mFrame->PresContext()->AppUnitsPerDevPixel());
   rect += mOffset;
 
-  aBuilder.PushIFrame(aSc.ToRelativeLayoutRect(rect),
+  aBuilder.PushIFrame(mozilla::wr::ToRoundedLayoutRect(rect),
       !BackfaceIsHidden(),
       mozilla::wr::AsPipelineId(GetRemoteLayersId()));
 
   return true;
 }
 
 bool
 nsDisplayRemote::UpdateScrollData(mozilla::layers::WebRenderScrollData* aData,
--- a/layout/painting/DisplayItemClip.cpp
+++ b/layout/painting/DisplayItemClip.cpp
@@ -454,17 +454,17 @@ DisplayItemClip::ToString() const
 
 void
 DisplayItemClip::ToComplexClipRegions(int32_t aAppUnitsPerDevPixel,
                                       const layers::StackingContextHelper& aSc,
                                       nsTArray<wr::ComplexClipRegion>& aOutArray) const
 {
   for (uint32_t i = 0; i < mRoundedClipRects.Length(); i++) {
     wr::ComplexClipRegion* region = aOutArray.AppendElement();
-    region->rect = aSc.ToRelativeLayoutRect(LayoutDeviceRect::FromAppUnits(
+    region->rect = wr::ToRoundedLayoutRect(LayoutDeviceRect::FromAppUnits(
         mRoundedClipRects[i].mRect, aAppUnitsPerDevPixel));
     const nscoord* radii = mRoundedClipRects[i].mRadii;
     region->radii = wr::ToBorderRadius(
         LayoutDeviceSize::FromAppUnits(nsSize(radii[eCornerTopLeftX], radii[eCornerTopLeftY]), aAppUnitsPerDevPixel),
         LayoutDeviceSize::FromAppUnits(nsSize(radii[eCornerTopRightX], radii[eCornerTopRightY]), aAppUnitsPerDevPixel),
         LayoutDeviceSize::FromAppUnits(nsSize(radii[eCornerBottomLeftX], radii[eCornerBottomLeftY]), aAppUnitsPerDevPixel),
         LayoutDeviceSize::FromAppUnits(nsSize(radii[eCornerBottomRightX], radii[eCornerBottomRightY]), aAppUnitsPerDevPixel));
     region->mode = wr::ClipMode::Clip;
--- a/layout/painting/nsCSSRenderingBorders.cpp
+++ b/layout/painting/nsCSSRenderingBorders.cpp
@@ -3421,37 +3421,37 @@ nsCSSBorderRenderer::DrawBorders()
 
 void
 nsCSSBorderRenderer::CreateWebRenderCommands(nsDisplayItem* aItem,
                                              wr::DisplayListBuilder& aBuilder,
                                              wr::IpcResourceUpdateQueue& aResources,
                                              const layers::StackingContextHelper& aSc)
 {
   LayoutDeviceRect outerRect = LayoutDeviceRect::FromUnknownRect(mOuterRect);
-  wr::LayoutRect transformedRect = aSc.ToRelativeLayoutRect(outerRect);
+  wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(outerRect);
   wr::BorderSide side[4];
   NS_FOR_CSS_SIDES(i) {
     side[i] = wr::ToBorderSide(ToDeviceColor(mBorderColors[i]), mBorderStyles[i]);
   }
 
   wr::BorderRadius borderRadius = wr::ToBorderRadius(LayoutDeviceSize::FromUnknownSize(mBorderRadii[0]),
                                                      LayoutDeviceSize::FromUnknownSize(mBorderRadii[1]),
                                                      LayoutDeviceSize::FromUnknownSize(mBorderRadii[3]),
                                                      LayoutDeviceSize::FromUnknownSize(mBorderRadii[2]));
 
   if (mLocalClip) {
     LayoutDeviceRect clip = LayoutDeviceRect::FromUnknownRect(mLocalClip.value());
-    wr::LayoutRect clipRect = aSc.ToRelativeLayoutRect(clip);
+    wr::LayoutRect clipRect = wr::ToRoundedLayoutRect(clip);
     wr::WrClipId clipId = aBuilder.DefineClip(Nothing(), Nothing(), clipRect);
     aBuilder.PushClip(clipId, aItem->GetClipChain());
   }
 
   Range<const wr::BorderSide> wrsides(side, 4);
-  aBuilder.PushBorder(transformedRect,
-                      transformedRect,
+  aBuilder.PushBorder(roundedRect,
+                      roundedRect,
                       mBackfaceIsVisible,
                       wr::ToBorderWidths(mBorderWidths[0], mBorderWidths[1], mBorderWidths[2], mBorderWidths[3]),
                       wrsides,
                       borderRadius);
 
   if (mLocalClip) {
     aBuilder.PopClip(aItem->GetClipChain());
   }
@@ -3693,23 +3693,23 @@ nsCSSBorderImageRenderer::CreateWebRende
   NS_FOR_CSS_SIDES(i) {
     slice[i] = (float)(mSlice.Side(i)) / appUnitsPerDevPixel;
     widths[i] = (float)(mWidths.Side(i)) / appUnitsPerDevPixel;
     outset[i] = (float)(mImageOutset.Side(i)) / appUnitsPerDevPixel;
   }
 
   LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits(
     mArea, appUnitsPerDevPixel);
-  wr::LayoutRect dest = aSc.ToRelativeLayoutRect(destRect);
+  wr::LayoutRect dest = wr::ToRoundedLayoutRect(destRect);
 
   wr::LayoutRect clip = dest;
   if (!mClip.IsEmpty()) {
     LayoutDeviceRect clipRect = LayoutDeviceRect::FromAppUnits(
       mClip, appUnitsPerDevPixel);
-    clip = aSc.ToRelativeLayoutRect(clipRect);
+    clip = wr::ToRoundedLayoutRect(clipRect);
   }
 
   switch (mImageRenderer.GetType()) {
     case eStyleImageType_Image:
     {
       uint32_t flags = imgIContainer::FLAG_ASYNC_NOTIFY;
       if (aDisplayListBuilder->IsPaintingToWindow()) {
         flags |= imgIContainer::FLAG_HIGH_QUALITY_SCALING;
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -3355,20 +3355,20 @@ bool
 nsDisplaySolidColor::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
                                              mozilla::wr::IpcResourceUpdateQueue& aResources,
                                              const StackingContextHelper& aSc,
                                              mozilla::layers::WebRenderLayerManager* aManager,
                                              nsDisplayListBuilder* aDisplayListBuilder)
 {
   LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
         mVisibleRect, mFrame->PresContext()->AppUnitsPerDevPixel());
-  wr::LayoutRect transformedRect = aSc.ToRelativeLayoutRect(bounds);
-
-  aBuilder.PushRect(transformedRect,
-                    transformedRect,
+  wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(bounds);
+
+  aBuilder.PushRect(roundedRect,
+                    roundedRect,
                     !BackfaceIsHidden(),
                     wr::ToColorF(ToDeviceColor(mColor)));
 
   return true;
 }
 
 nsRect
 nsDisplaySolidColorRegion::GetBounds(nsDisplayListBuilder* aBuilder,
@@ -3408,19 +3408,19 @@ nsDisplaySolidColorRegion::CreateWebRend
                                                    const StackingContextHelper& aSc,
                                                    mozilla::layers::WebRenderLayerManager* aManager,
                                                    nsDisplayListBuilder* aDisplayListBuilder)
 {
   for (auto iter = mRegion.RectIter(); !iter.Done(); iter.Next()) {
     nsRect rect = iter.Get();
     LayoutDeviceRect layerRects = LayoutDeviceRect::FromAppUnits(
       rect, mFrame->PresContext()->AppUnitsPerDevPixel());
-    wr::LayoutRect transformedRect = aSc.ToRelativeLayoutRect(layerRects);
-    aBuilder.PushRect(transformedRect,
-                      transformedRect,
+    wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(layerRects);
+    aBuilder.PushRect(roundedRect,
+                      roundedRect,
                       !BackfaceIsHidden(),
                       wr::ToColorF(ToDeviceColor(mColor)));
   }
 
   return true;
 }
 
 static void
@@ -4735,20 +4735,20 @@ nsDisplayBackgroundColor::CreateWebRende
 
   StyleGeometryBox clip = mBackgroundStyle->mImage.mLayers[0].mClip;
   if (clip == StyleGeometryBox::Text) {
     return false;
   }
 
   LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
         mBackgroundRect, mFrame->PresContext()->AppUnitsPerDevPixel());
-  wr::LayoutRect transformedRect = aSc.ToRelativeLayoutRect(bounds);
-
-  aBuilder.PushRect(transformedRect,
-                    transformedRect,
+  wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(bounds);
+
+  aBuilder.PushRect(roundedRect,
+                    roundedRect,
                     !BackfaceIsHidden(),
                     wr::ToColorF(ToDeviceColor(mColor)));
 
   return true;
 }
 
 void
 nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,
@@ -4882,17 +4882,17 @@ nsDisplayClearBackground::CreateWebRende
                                                   const StackingContextHelper& aSc,
                                                   mozilla::layers::WebRenderLayerManager* aManager,
                                                   nsDisplayListBuilder* aDisplayListBuilder)
 {
   LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
     nsRect(ToReferenceFrame(), mFrame->GetSize()),
     mFrame->PresContext()->AppUnitsPerDevPixel());
 
-  aBuilder.PushClearRect(aSc.ToRelativeLayoutRect(bounds));
+  aBuilder.PushClearRect(wr::ToRoundedLayoutRect(bounds));
 
   return true;
 }
 
 nsRect
 nsDisplayOutline::GetBounds(nsDisplayListBuilder* aBuilder,
                             bool* aSnap) const
 {
@@ -5049,17 +5049,17 @@ nsDisplayCompositorHitTestInfo::CreateWe
       });
 
   // Insert a transparent rectangle with the hit-test info
   aBuilder.SetHitTestInfo(scrollId, mHitTestInfo);
 
   const LayoutDeviceRect devRect =
     LayoutDeviceRect::FromAppUnits(mArea, mAppUnitsPerDevPixel);
 
-  const wr::LayoutRect rect = aSc.ToRelativeLayoutRect(devRect);
+  const wr::LayoutRect rect = wr::ToRoundedLayoutRect(devRect);
 
   aBuilder.PushRect(rect, rect, true, wr::ToColorF(gfx::Color()));
   aBuilder.ClearHitTestInfo();
 
   return true;
 }
 
 void
@@ -5339,18 +5339,18 @@ nsDisplayCaret::CreateWebRenderCommands(
   mCaret->ComputeCaretRects(frame, contentOffset, &caretRect, &hookRect);
 
   gfx::Color color = ToDeviceColor(frame->GetCaretColorAt(contentOffset));
   LayoutDeviceRect devCaretRect = LayoutDeviceRect::FromAppUnits(
     caretRect + ToReferenceFrame(), appUnitsPerDevPixel);
   LayoutDeviceRect devHookRect = LayoutDeviceRect::FromAppUnits(
     hookRect + ToReferenceFrame(), appUnitsPerDevPixel);
 
-  wr::LayoutRect caret = aSc.ToRelativeLayoutRect(devCaretRect);
-  wr::LayoutRect hook = aSc.ToRelativeLayoutRect(devHookRect);
+  wr::LayoutRect caret = wr::ToRoundedLayoutRect(devCaretRect);
+  wr::LayoutRect hook = wr::ToRoundedLayoutRect(devHookRect);
 
   // Note, WR will pixel snap anything that is layout aligned.
   aBuilder.PushRect(caret,
                     caret,
                     !BackfaceIsHidden(),
                     wr::ToColorF(color));
 
   if (!devHookRect.IsEmpty()) {
@@ -5547,23 +5547,23 @@ nsDisplayBorder::CreateBorderImageWebRen
   NS_FOR_CSS_SIDES(i) {
     slice[i] = (float)(mBorderImageRenderer->mSlice.Side(i)) / appUnitsPerDevPixel;
     widths[i] = (float)(mBorderImageRenderer->mWidths.Side(i)) / appUnitsPerDevPixel;
     outset[i] = (float)(mBorderImageRenderer->mImageOutset.Side(i)) / appUnitsPerDevPixel;
   }
 
   LayoutDeviceRect destRect = LayoutDeviceRect::FromAppUnits(
     mBorderImageRenderer->mArea, appUnitsPerDevPixel);
-  wr::LayoutRect dest = aSc.ToRelativeLayoutRect(destRect);
+  wr::LayoutRect dest = wr::ToRoundedLayoutRect(destRect);
 
   wr::LayoutRect clip = dest;
   if (!mBorderImageRenderer->mClip.IsEmpty()) {
     LayoutDeviceRect clipRect = LayoutDeviceRect::FromAppUnits(
       mBorderImageRenderer->mClip, appUnitsPerDevPixel);
-    clip = aSc.ToRelativeLayoutRect(clipRect);
+    clip = wr::ToRoundedLayoutRect(clipRect);
   }
 
   switch (mBorderImageRenderer->mImageRenderer.GetType()) {
     case eStyleImageType_Image:
     {
       uint32_t flags = imgIContainer::FLAG_ASYNC_NOTIFY;
       if (aDisplayListBuilder->IsPaintingToWindow()) {
         flags |= imgIContainer::FLAG_HIGH_QUALITY_SCALING;
@@ -5850,18 +5850,18 @@ nsDisplayBoxShadowOuter::CreateWebRender
       // Now translate everything to device pixels.
       nsRect shadowRect = frameRect;
       LayoutDevicePoint shadowOffset = LayoutDevicePoint::FromAppUnits(
           nsPoint(shadow->mXOffset, shadow->mYOffset),
           appUnitsPerDevPixel);
 
       LayoutDeviceRect deviceBox = LayoutDeviceRect::FromAppUnits(
           shadowRect, appUnitsPerDevPixel);
-      wr::LayoutRect deviceBoxRect = aSc.ToRelativeLayoutRect(deviceBox);
-      wr::LayoutRect deviceClipRect = aSc.ToRelativeLayoutRect(clipRect);
+      wr::LayoutRect deviceBoxRect = wr::ToRoundedLayoutRect(deviceBox);
+      wr::LayoutRect deviceClipRect = wr::ToRoundedLayoutRect(clipRect);
 
       LayoutDeviceSize zeroSize;
       wr::BorderRadius borderRadius = wr::ToBorderRadius(zeroSize, zeroSize,
                                                          zeroSize, zeroSize);
       if (hasBorderRadius) {
         borderRadius = wr::ToBorderRadius(
           LayoutDeviceSize::FromUnknownSize(borderRadii.TopLeft()),
           LayoutDeviceSize::FromUnknownSize(borderRadii.TopRight()),
@@ -5993,17 +5993,17 @@ nsDisplayBoxShadowInner::CreateInsetBoxS
       nsRect shadowRect =
         nsCSSRendering::GetBoxShadowInnerPaddingRect(aFrame, aBorderRect);
       RectCornerRadii innerRadii;
       nsCSSRendering::GetShadowInnerRadii(aFrame, aBorderRect, innerRadii);
 
       // Now translate everything to device pixels.
       LayoutDeviceRect deviceBoxRect = LayoutDeviceRect::FromAppUnits(
           shadowRect, appUnitsPerDevPixel);
-      wr::LayoutRect deviceClipRect = aSc.ToRelativeLayoutRect(clipRect);
+      wr::LayoutRect deviceClipRect = wr::ToRoundedLayoutRect(clipRect);
       Color shadowColor = nsCSSRendering::GetShadowColor(shadowItem, aFrame, 1.0);
 
       LayoutDevicePoint shadowOffset = LayoutDevicePoint::FromAppUnits(
           nsPoint(shadowItem->mXOffset, shadowItem->mYOffset),
           appUnitsPerDevPixel);
 
       float blurRadius = float(shadowItem->mRadius) / float(appUnitsPerDevPixel);
 
@@ -7602,17 +7602,17 @@ nsDisplayStickyPosition::CreateWebRender
       }
     }
 
     LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(itemBounds, auPerDevPixel);
     wr::LayoutVector2D applied = {
       NSAppUnitsToFloatPixels(appliedOffset.x, auPerDevPixel),
       NSAppUnitsToFloatPixels(appliedOffset.y, auPerDevPixel)
     };
-    wr::WrStickyId id = aBuilder.DefineStickyFrame(aSc.ToRelativeLayoutRect(bounds),
+    wr::WrStickyId id = aBuilder.DefineStickyFrame(wr::ToRoundedLayoutRect(bounds),
         topMargin.ptrOr(nullptr), rightMargin.ptrOr(nullptr),
         bottomMargin.ptrOr(nullptr), leftMargin.ptrOr(nullptr),
         vBounds, hBounds, applied);
 
     aBuilder.PushStickyFrame(id, GetClipChain());
   }
 
   nsDisplayOwnLayer::CreateWebRenderCommands(aBuilder, aResources, aSc,
@@ -9643,17 +9643,17 @@ nsDisplayMask::CreateWebRenderCommands(m
   nsRect displayBound = GetBounds(aDisplayListBuilder, &snap);
   LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(displayBound, appUnitsPerDevPixel);
 
   Maybe<wr::WrImageMask> mask = aManager->CommandBuilder().BuildWrMaskImage(this, aBuilder, aResources,
                                                                             aSc, aDisplayListBuilder,
                                                                             bounds);
   if (mask) {
     wr::WrClipId clipId = aBuilder.DefineClip(Nothing(), Nothing(),
-        aSc.ToRelativeLayoutRect(bounds), nullptr, mask.ptr());
+        wr::ToRoundedLayoutRect(bounds), nullptr, mask.ptr());
     // Don't record this clip push in aBuilder's internal clip stack, because
     // otherwise any nested ScrollingLayersHelper instances that are created
     // will get confused about which clips are pushed.
     aBuilder.PushClip(clipId, GetClipChain());
   }
 
   nsDisplaySVGEffects::CreateWebRenderCommands(aBuilder, aResources, aSc, aManager, aDisplayListBuilder);
 
--- a/layout/painting/nsImageRenderer.cpp
+++ b/layout/painting/nsImageRenderer.cpp
@@ -627,18 +627,18 @@ nsImageRenderer::BuildWebRenderDisplayIt
 
       nsPoint firstTilePos = nsLayoutUtils::GetBackgroundFirstTilePos(aDest.TopLeft(),
                                                                       aFill.TopLeft(),
                                                                       aRepeatSize);
       LayoutDeviceRect fillRect = LayoutDeviceRect::FromAppUnits(
           nsRect(firstTilePos.x, firstTilePos.y,
                  aFill.XMost() - firstTilePos.x, aFill.YMost() - firstTilePos.y),
           appUnitsPerDevPixel);
-      wr::LayoutRect fill = aSc.ToRelativeLayoutRect(fillRect);
-      wr::LayoutRect clip = aSc.ToRelativeLayoutRect(
+      wr::LayoutRect fill = wr::ToRoundedLayoutRect(fillRect);
+      wr::LayoutRect clip = wr::ToRoundedLayoutRect(
           LayoutDeviceRect::FromAppUnits(aFill, appUnitsPerDevPixel));
 
       LayoutDeviceSize gapSize = LayoutDeviceSize::FromAppUnits(
           aRepeatSize - aDest.Size(), appUnitsPerDevPixel);
 
       SamplingFilter samplingFilter = nsLayoutUtils::GetSamplingFilterForFrame(mForFrame);
       aBuilder.PushImage(fill, clip, !aItem->BackfaceIsHidden(),
                          wr::ToLayoutSize(destRect.Size()), wr::ToLayoutSize(gapSize),
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -7504,34 +7504,34 @@ BCBlockDirSeg::CreateWebRenderCommands(B
     }
 
     return;
   }
 
   LayoutDeviceRect borderRect = LayoutDeviceRect::FromUnknownRect(NSRectToRect(param->mBorderRect + aOffset,
                                                                                param->mAppUnitsPerDevPixel));
 
-  wr::LayoutRect transformedRect = aSc.ToRelativeLayoutRect(borderRect);
+  wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(borderRect);
   wr::BorderSide wrSide[4];
   NS_FOR_CSS_SIDES(i) {
     wrSide[i] = wr::ToBorderSide(ToDeviceColor(param->mBorderColor), NS_STYLE_BORDER_STYLE_NONE);
   }
   wrSide[eSideLeft] = wr::ToBorderSide(ToDeviceColor(param->mBorderColor), param->mBorderStyle);
 
   wr::BorderRadius borderRadii = wr::EmptyBorderRadius();
 
   // All border style is set to none except left side. So setting the widths of
   // each side to width of rect is fine.
-  wr::BorderWidths borderWidths = wr::ToBorderWidths(transformedRect.size.width,
-                                                     transformedRect.size.width,
-                                                     transformedRect.size.width,
-                                                     transformedRect.size.width);
+  wr::BorderWidths borderWidths = wr::ToBorderWidths(roundedRect.size.width,
+                                                     roundedRect.size.width,
+                                                     roundedRect.size.width,
+                                                     roundedRect.size.width);
   Range<const wr::BorderSide> wrsides(wrSide, 4);
-  aBuilder.PushBorder(transformedRect,
-                      transformedRect,
+  aBuilder.PushBorder(roundedRect,
+                      roundedRect,
                       param->mBackfaceIsVisible,
                       borderWidths,
                       wrsides,
                       borderRadii);
 }
 
 /**
  * Advance the start point of a segment
@@ -7786,34 +7786,34 @@ BCInlineDirSeg::CreateWebRenderCommands(
         break;
     }
 
     return;
   }
 
   LayoutDeviceRect borderRect = LayoutDeviceRect::FromUnknownRect(NSRectToRect(param->mBorderRect + aPt,
                                                                                param->mAppUnitsPerDevPixel));
-  wr::LayoutRect transformedRect = aSc.ToRelativeLayoutRect(borderRect);
+  wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(borderRect);
   wr::BorderSide wrSide[4];
   NS_FOR_CSS_SIDES(i) {
     wrSide[i] = wr::ToBorderSide(ToDeviceColor(param->mBorderColor), NS_STYLE_BORDER_STYLE_NONE);
   }
   wrSide[eSideTop] = wr::ToBorderSide(ToDeviceColor(param->mBorderColor), param->mBorderStyle);
 
   wr::BorderRadius borderRadii = wr::EmptyBorderRadius();
 
   // All border style is set to none except top side. So setting the widths of
   // each side to height of rect is fine.
-  wr::BorderWidths borderWidths = wr::ToBorderWidths(transformedRect.size.height,
-                                                     transformedRect.size.height,
-                                                     transformedRect.size.height,
-                                                     transformedRect.size.height);
+  wr::BorderWidths borderWidths = wr::ToBorderWidths(roundedRect.size.height,
+                                                     roundedRect.size.height,
+                                                     roundedRect.size.height,
+                                                     roundedRect.size.height);
   Range<const wr::BorderSide> wrsides(wrSide, 4);
-  aBuilder.PushBorder(transformedRect,
-                      transformedRect,
+  aBuilder.PushBorder(roundedRect,
+                      roundedRect,
                       param->mBackfaceIsVisible,
                       borderWidths,
                       wrsides,
                       borderRadii);
 }
 
 /**
  * Advance the start point of a segment
@@ -8057,40 +8057,40 @@ nsTableFrame::CreateWebRenderCommandsFor
     if (param.isSome()) {
       borderRect = LayoutDeviceRect::FromUnknownRect(NSRectToRect(param->mBorderRect + aOffsetToReferenceFrame,
                                                                   param->mAppUnitsPerDevPixel));
       borderColor = param->mBorderColor;
       borderStyle = param->mBorderStyle;
       backfaceIsVisible |= param->mBackfaceIsVisible;
     }
 
-    wr::LayoutRect transformedRect = aSc.ToRelativeLayoutRect(borderRect);
+    wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(borderRect);
     allBorderRect = allBorderRect.Union(borderRect);
     wrSide[side] = wr::ToBorderSide(ToDeviceColor(borderColor), borderStyle);
     switch (side) {
       case eSideTop:
-        wrWidths.top = transformedRect.size.height;
+        wrWidths.top = roundedRect.size.height;
         break;
       case eSideBottom:
-        wrWidths.bottom = transformedRect.size.height;
+        wrWidths.bottom = roundedRect.size.height;
         break;
       case eSideLeft:
-        wrWidths.left = transformedRect.size.width;
+        wrWidths.left = roundedRect.size.width;
         break;
       case eSideRight:
-        wrWidths.right = transformedRect.size.width;
+        wrWidths.right = roundedRect.size.width;
         break;
     }
   }
 
   if (!allBorderRect.IsEmpty()) {
     Range<const wr::BorderSide> wrsides(wrSide, 4);
-    wr::LayoutRect allTransformedRect = aSc.ToRelativeLayoutRect(allBorderRect);
-    aBuilder.PushBorder(allTransformedRect,
-                        allTransformedRect,
+    wr::LayoutRect allRoundedRect = wr::ToRoundedLayoutRect(allBorderRect);
+    aBuilder.PushBorder(allRoundedRect,
+                        allRoundedRect,
                         backfaceIsVisible,
                         wrWidths,
                         wrsides,
                         borderRadii);
   }
 }
 
 bool
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -460,17 +460,17 @@ nsImageBoxFrame::CreateWebRenderCommands
 
   gfx::IntSize size;
   Maybe<wr::ImageKey> key = aManager->CommandBuilder().CreateImageKey(aItem, container,
                                                                       aBuilder, aResources,
                                                                       aSc, size, Nothing());
   if (key.isNothing()) {
     return ImgDrawResult::NOT_READY;
   }
-  wr::LayoutRect fill = aSc.ToRelativeLayoutRect(fillRect);
+  wr::LayoutRect fill = wr::ToRoundedLayoutRect(fillRect);
 
   LayoutDeviceSize gapSize(0, 0);
   SamplingFilter sampleFilter = nsLayoutUtils::GetSamplingFilterForFrame(aItem->Frame());
   aBuilder.PushImage(fill, fill, !BackfaceIsHidden(),
                      wr::ToLayoutSize(fillRect.Size()), wr::ToLayoutSize(gapSize),
                      wr::ToImageRendering(sampleFilter), key.value());
 
   return ImgDrawResult::SUCCESS;
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -2976,17 +2976,17 @@ nsNativeThemeCocoa::CreateWebRenderComma
                                                      mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                      const mozilla::layers::StackingContextHelper& aSc,
                                                      mozilla::layers::WebRenderLayerManager* aManager,
                                                      nsIFrame* aFrame,
                                                      uint8_t aWidgetType,
                                                      const nsRect& aRect)
 {
   nsPresContext* presContext = aFrame->PresContext();
-  wr::LayoutRect bounds = aSc.ToRelativeLayoutRect(
+  wr::LayoutRect bounds = wr::ToRoundedLayoutRect(
     LayoutDeviceRect::FromAppUnits(aRect, presContext->AppUnitsPerDevPixel()));
 
   EventStates eventState = GetContentState(aFrame, aWidgetType);
 
   // This list needs to stay consistent with the list in DrawWidgetBackground.
   // For every switch case in DrawWidgetBackground, there are three choices:
   //  - If the case in DrawWidgetBackground draws nothing for the given widget
   //    type, then don't list it here. We will hit the "default: return true;"
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -1210,17 +1210,17 @@ nsNativeThemeGTK::CreateWebRenderCommand
                                                    mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                    const mozilla::layers::StackingContextHelper& aSc,
                                                    mozilla::layers::WebRenderLayerManager* aManager,
                                                    nsIFrame* aFrame,
                                                    uint8_t aWidgetType,
                                                    const nsRect& aRect)
 {
   nsPresContext* presContext = aFrame->PresContext();
-  wr::LayoutRect bounds = aSc.ToRelativeLayoutRect(
+  wr::LayoutRect bounds = wr::ToRoundedLayoutRect(
     LayoutDeviceRect::FromAppUnits(aRect, presContext->AppUnitsPerDevPixel()));
 
   switch (aWidgetType) {
   case NS_THEME_WINDOW:
   case NS_THEME_DIALOG:
     aBuilder.PushRect(bounds, bounds, true,
                       wr::ToColorF(Color::FromABGR(
                         LookAndFeel::GetColor(LookAndFeel::eColorID_WindowBackground,