diff --git a/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js b/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
index 0de6e02de080..c83267509bc0 100644
--- a/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js
@@ -351,6 +351,8 @@ function moveMouseAndScrollWheelOver(element, dx, dy, testDriver, waitForScroll
// processed by the widget code can be detected by listening for the mousemove
// events in the caller, or for some other event that is triggered by the
// mousemove, such as the scroll event resulting from the scrollbar drag.
+// Note: helper_scrollbar_snap_bug1501062.html contains a copy of this code
+// with modifications. Fixes here should be copied there if appropriate.
function* dragVerticalScrollbar(element, testDriver, distance = 20, increment = 5) {
var boundingClientRect = element.getBoundingClientRect();
var verticalScrollbarWidth = boundingClientRect.width - element.clientWidth;
diff --git a/gfx/layers/apz/test/mochitest/helper_scrollbar_snap_bug1501062.html b/gfx/layers/apz/test/mochitest/helper_scrollbar_snap_bug1501062.html
new file mode 100644
index 000000000000..55bef5b70a4f
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_scrollbar_snap_bug1501062.html
@@ -0,0 +1,99 @@
+
+
+
+
+
+ Exercising the slider.snapMultiplier code
+
+
+
+
+
+
+
+
+
diff --git a/gfx/layers/apz/test/mochitest/test_group_mouseevents.html b/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
index 275d01a9fc48..5d8b890ab93c 100644
--- a/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
+++ b/gfx/layers/apz/test/mochitest/test_group_mouseevents.html
@@ -25,7 +25,10 @@ var subtests = [
// Test for scrollbar-dragging on a scrollframe inside an SVGEffects
{'file': 'helper_bug1331693.html'},
// Test for scrollbar-dragging on a transformed scrollframe inside a fixed-pos item
- {'file': 'helper_bug1462961.html'}
+ {'file': 'helper_bug1462961.html'},
+ // Scrollbar dragging where we exercise the snapback behaviour by moving the
+ // mouse away from the scrollbar during drag
+ {'file': 'helper_scrollbar_snap_bug1501062.html'}
];
if (isApzEnabled()) {
diff --git a/gfx/layers/wr/WebRenderScrollData.h b/gfx/layers/wr/WebRenderScrollData.h
index 3dc01cc68771..959bf60c7cfe 100644
--- a/gfx/layers/wr/WebRenderScrollData.h
+++ b/gfx/layers/wr/WebRenderScrollData.h
@@ -74,6 +74,7 @@ public:
void SetEventRegionsOverride(const EventRegionsOverride& aOverride) { mEventRegionsOverride = aOverride; }
EventRegionsOverride GetEventRegionsOverride() const { return mEventRegionsOverride; }
+ void SetVisibleRegion(const LayerIntRegion& aRegion) { mVisibleRegion = aRegion; }
const LayerIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
void SetReferentId(LayersId aReferentId) { mReferentId = Some(aReferentId); }
Maybe GetReferentId() const { return mReferentId; }
diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp
index a2cd8ce381a0..28b7c47f6444 100644
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -7118,6 +7118,12 @@ nsDisplayOwnLayer::UpdateScrollData(
aLayerData->SetScrollbarData(mScrollbarData);
if (IsScrollThumbLayer()) {
aLayerData->SetScrollbarAnimationId(mWrAnimationId);
+ LayoutDeviceRect bounds = LayoutDeviceIntRect::FromAppUnits(
+ mBounds, mFrame->PresContext()->AppUnitsPerDevPixel());
+ // Assume a resolution of 1.0 for now because this is a WebRender codepath
+ // and we don't really handle resolution on the Gecko side
+ LayerIntRect layerBounds = RoundedOut(bounds * LayoutDeviceToLayerScale(1.0f));
+ aLayerData->SetVisibleRegion(LayerIntRegion(layerBounds));
}
}
}