Skip to content

Commit 954d9f6

Browse files
committedDec 5, 2024
Bug 1934164. Remove unused scroll grab code. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D230635
1 parent 9111bf4 commit 954d9f6

13 files changed

+4
-189
lines changed
 

‎dom/base/nsContentUtils.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -6948,13 +6948,6 @@ void* nsContentUtils::AllocClassMatchingInfo(nsINode* aRootNode,
69486948
return info;
69496949
}
69506950

6951-
bool nsContentUtils::HasScrollgrab(nsIContent* aContent) {
6952-
// If we ever standardize this feature we'll want to hook this up properly
6953-
// again. For now we're removing all the DOM-side code related to it but
6954-
// leaving the layout and APZ handling for it in place.
6955-
return false;
6956-
}
6957-
69586951
void nsContentUtils::FlushLayoutForTree(nsPIDOMWindowOuter* aWindow) {
69596952
if (!aWindow) {
69606953
return;

‎dom/base/nsContentUtils.h

-6
Original file line numberDiff line numberDiff line change
@@ -2532,12 +2532,6 @@ class nsContentUtils {
25322532
static void GetAltText(nsAString& text);
25332533
static void GetModifierSeparatorText(nsAString& text);
25342534

2535-
/**
2536-
* Returns if aContent has the 'scrollgrab' property.
2537-
* aContent may be null (in this case false is returned).
2538-
*/
2539-
static bool HasScrollgrab(nsIContent* aContent);
2540-
25412535
/**
25422536
* Flushes the layout tree (recursively)
25432537
*

‎gfx/layers/FrameMetrics.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,6 @@ std::ostream& operator<<(std::ostream& aStream,
267267
if (aMetadata.GetScrollParentId() != ScrollableLayerGuid::NULL_SCROLL_ID) {
268268
aStream << "] [scrollParent=" << aMetadata.GetScrollParentId();
269269
}
270-
if (aMetadata.GetHasScrollgrab()) {
271-
aStream << "] [scrollgrab";
272-
}
273270
aStream << "] [overscroll=" << aMetadata.GetOverscrollBehavior() << "] ["
274271
<< aMetadata.GetScrollUpdates().Length() << " scrollupdates"
275272
<< "] }";

‎gfx/layers/FrameMetrics.h

-9
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ struct ScrollMetadata {
752752
mPageScrollAmount(0, 0),
753753
mInteractiveWidget(
754754
dom::InteractiveWidgetUtils::DefaultInteractiveWidgetMode()),
755-
mHasScrollgrab(false),
756755
mIsLayersIdRoot(false),
757756
mIsAutoDirRootContentRTL(false),
758757
mForceDisableApz(false),
@@ -771,7 +770,6 @@ struct ScrollMetadata {
771770
mLineScrollAmount == aOther.mLineScrollAmount &&
772771
mPageScrollAmount == aOther.mPageScrollAmount &&
773772
mInteractiveWidget == aOther.mInteractiveWidget &&
774-
mHasScrollgrab == aOther.mHasScrollgrab &&
775773
mIsLayersIdRoot == aOther.mIsLayersIdRoot &&
776774
mIsAutoDirRootContentRTL == aOther.mIsAutoDirRootContentRTL &&
777775
mForceDisableApz == aOther.mForceDisableApz &&
@@ -827,10 +825,6 @@ struct ScrollMetadata {
827825
void SetPageScrollAmount(const LayoutDeviceIntSize& size) {
828826
mPageScrollAmount = size;
829827
}
830-
void SetHasScrollgrab(bool aHasScrollgrab) {
831-
mHasScrollgrab = aHasScrollgrab;
832-
}
833-
bool GetHasScrollgrab() const { return mHasScrollgrab; }
834828
void SetIsLayersIdRoot(bool aValue) { mIsLayersIdRoot = aValue; }
835829
bool IsLayersIdRoot() const { return mIsLayersIdRoot; }
836830
void SetIsAutoDirRootContentRTL(bool aValue) {
@@ -957,9 +951,6 @@ struct ScrollMetadata {
957951
// be checked on AsyncPanZoomController::mScrollMetadata.
958952
dom::InteractiveWidget mInteractiveWidget;
959953

960-
// Whether or not this frame is for an element marked 'scrollgrab'.
961-
bool mHasScrollgrab : 1;
962-
963954
// Whether these framemetrics are for the root scroll frame (root element if
964955
// we don't have a root scroll frame) for its layers id.
965956
bool mIsLayersIdRoot : 1;

‎gfx/layers/apz/src/APZCTreeManager.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -3076,11 +3076,6 @@ APZCTreeManager::BuildOverscrollHandoffChain(
30763076
apzc = scrollParent.get();
30773077
}
30783078

3079-
// Now adjust the chain to account for scroll grabbing. Sorting is a bit
3080-
// of an overkill here, but scroll grabbing will likely be generalized
3081-
// to scroll priorities, so we might as well do it this way.
3082-
result->SortByScrollPriority();
3083-
30843079
// Print the overscroll chain for debugging.
30853080
for (uint32_t i = 0; i < result->Length(); ++i) {
30863081
APZCTM_LOG("OverscrollHandoffChain[%d] = %p\n", i,

‎gfx/layers/apz/src/AsyncPanZoomController.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -5671,7 +5671,6 @@ void AsyncPanZoomController::NotifyLayersUpdated(
56715671
Metrics().SetCumulativeResolution(aLayerMetrics.GetCumulativeResolution());
56725672
Metrics().SetTransformToAncestorScale(
56735673
aLayerMetrics.GetTransformToAncestorScale());
5674-
mScrollMetadata.SetHasScrollgrab(aScrollMetadata.GetHasScrollgrab());
56755674
mScrollMetadata.SetLineScrollAmount(aScrollMetadata.GetLineScrollAmount());
56765675
mScrollMetadata.SetPageScrollAmount(aScrollMetadata.GetPageScrollAmount());
56775676
mScrollMetadata.SetSnapInfo(ScrollSnapInfo(aScrollMetadata.GetSnapInfo()));

‎gfx/layers/apz/src/AsyncPanZoomController.h

-6
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,6 @@ class AsyncPanZoomController {
447447
void ClearOverscroll();
448448
void ClearPhysicalOverscroll();
449449

450-
/**
451-
* Returns whether this APZC is for an element marked with the 'scrollgrab'
452-
* attribute.
453-
*/
454-
bool HasScrollgrab() const { return mScrollMetadata.GetHasScrollgrab(); }
455-
456450
/**
457451
* Returns whether this APZC has scroll snap points.
458452
*/

‎gfx/layers/apz/src/OverscrollHandoffState.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,6 @@ void OverscrollHandoffChain::Add(AsyncPanZoomController* aApzc) {
2020
mChain.push_back(aApzc);
2121
}
2222

23-
struct CompareByScrollPriority {
24-
bool operator()(const RefPtr<AsyncPanZoomController>& a,
25-
const RefPtr<AsyncPanZoomController>& b) const {
26-
return a->HasScrollgrab() && !b->HasScrollgrab();
27-
}
28-
};
29-
30-
void OverscrollHandoffChain::SortByScrollPriority() {
31-
// The sorting being stable ensures that the relative order between
32-
// non-scrollgrabbing APZCs remains child -> parent.
33-
// (The relative order between scrollgrabbing APZCs will also remain
34-
// child -> parent, though that's just an artefact of the implementation
35-
// and users of 'scrollgrab' should not rely on this.)
36-
std::stable_sort(mChain.begin(), mChain.end(), CompareByScrollPriority());
37-
}
38-
3923
const RefPtr<AsyncPanZoomController>& OverscrollHandoffChain::GetApzcAtIndex(
4024
uint32_t aIndex) const {
4125
MOZ_ASSERT(aIndex < Length());

‎gfx/layers/apz/src/OverscrollHandoffState.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ class AsyncPanZoomController;
2626
* This class represents the chain of APZCs along which overscroll is handed
2727
* off. It is created by APZCTreeManager by starting from an initial APZC which
2828
* is the target for input events, and following the scroll parent ID links
29-
* (often but not always corresponding to parent pointers in the APZC tree),
30-
* then adjusting for scrollgrab.
29+
* (often but not always corresponding to parent pointers in the APZC tree).
3130
*/
3231
class OverscrollHandoffChain {
3332
protected:

‎gfx/layers/apz/test/gtest/TestScrollHandoff.cpp

-117
Original file line numberDiff line numberDiff line change
@@ -142,67 +142,6 @@ class APZScrollHandoffTester : public APZCTreeManagerTester {
142142
rootApzc = ApzcOf(root);
143143
}
144144

145-
void CreateScrollgrabLayerTree(bool makeParentScrollable = true) {
146-
const char* treeShape = "x(x)";
147-
LayerIntRect layerVisibleRect[] = {
148-
LayerIntRect(0, 0, 100, 100), // scroll-grabbing parent
149-
LayerIntRect(0, 20, 100, 80) // child
150-
};
151-
CreateScrollData(treeShape, layerVisibleRect);
152-
float parentHeight = makeParentScrollable ? 120 : 100;
153-
SetScrollableFrameMetrics(root, ScrollableLayerGuid::START_SCROLL_ID,
154-
CSSRect(0, 0, 100, parentHeight));
155-
SetScrollableFrameMetrics(layers[1],
156-
ScrollableLayerGuid::START_SCROLL_ID + 1,
157-
CSSRect(0, 0, 100, 800));
158-
SetScrollHandoff(layers[1], root);
159-
registration = MakeUnique<ScopedLayerTreeRegistration>(LayersId{0}, mcc);
160-
UpdateHitTestingTree();
161-
rootApzc = ApzcOf(root);
162-
rootApzc->GetScrollMetadata().SetHasScrollgrab(true);
163-
}
164-
165-
void TestFlingAcceleration() {
166-
// Jack up the fling acceleration multiplier so we can easily determine
167-
// whether acceleration occured.
168-
const float kAcceleration = 100.0f;
169-
SCOPED_GFX_PREF_FLOAT("apz.fling_accel_base_mult", kAcceleration);
170-
SCOPED_GFX_PREF_FLOAT("apz.fling_accel_min_fling_velocity", 0.0);
171-
SCOPED_GFX_PREF_FLOAT("apz.fling_accel_min_pan_velocity", 0.0);
172-
173-
RefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
174-
175-
// Pan once, enough to fully scroll the scrollgrab parent and then scroll
176-
// and fling the child.
177-
QueueMockHitResult(ScrollableLayerGuid::START_SCROLL_ID + 1);
178-
Pan(manager, 70, 40);
179-
180-
// Give the fling animation a chance to start.
181-
SampleAnimationsOnce();
182-
183-
float childVelocityAfterFling1 = childApzc->GetVelocityVector().y;
184-
185-
// Pan again.
186-
QueueMockHitResult(ScrollableLayerGuid::START_SCROLL_ID + 1);
187-
Pan(manager, 70, 40);
188-
189-
// Give the fling animation a chance to start.
190-
// This time it should be accelerated.
191-
SampleAnimationsOnce();
192-
193-
float childVelocityAfterFling2 = childApzc->GetVelocityVector().y;
194-
195-
// We should have accelerated once.
196-
// The division by 2 is to account for friction.
197-
EXPECT_GT(childVelocityAfterFling2,
198-
childVelocityAfterFling1 * kAcceleration / 2);
199-
200-
// We should not have accelerated twice.
201-
// The division by 4 is to account for friction.
202-
EXPECT_LE(childVelocityAfterFling2,
203-
childVelocityAfterFling1 * kAcceleration * kAcceleration / 4);
204-
}
205-
206145
void TestCrossApzcAxisLock() {
207146
SCOPED_GFX_PREF_INT("apz.axis_lock.mode", 1);
208147

@@ -567,62 +506,6 @@ TEST_F(APZScrollHandoffTester, SimultaneousFlings) {
567506
parent2->AssertStateIsFling();
568507
}
569508

570-
#ifndef MOZ_WIDGET_ANDROID // Currently fails on Android
571-
TEST_F(APZScrollHandoffTester, Scrollgrab) {
572-
SCOPED_GFX_PREF_BOOL("apz.allow_immediate_handoff", true);
573-
574-
// Set up the layer tree
575-
CreateScrollgrabLayerTree();
576-
577-
RefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
578-
579-
// Pan on the child, enough to fully scroll the scrollgrab parent (20 px)
580-
// and leave some more (another 15 px) for the child.
581-
Pan(childApzc, 80, 45);
582-
583-
// Check that the parent and child have scrolled as much as we expect.
584-
EXPECT_EQ(20, rootApzc->GetFrameMetrics().GetVisualScrollOffset().y);
585-
EXPECT_EQ(15, childApzc->GetFrameMetrics().GetVisualScrollOffset().y);
586-
}
587-
#endif
588-
589-
TEST_F(APZScrollHandoffTester, ScrollgrabFling) {
590-
SCOPED_GFX_PREF_BOOL("apz.allow_immediate_handoff", true);
591-
SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
592-
593-
// Set up the layer tree
594-
CreateScrollgrabLayerTree();
595-
596-
RefPtr<TestAsyncPanZoomController> childApzc = ApzcOf(layers[1]);
597-
598-
// Pan on the child, not enough to fully scroll the scrollgrab parent.
599-
Pan(childApzc, 80, 70);
600-
601-
// Check that it is the scrollgrab parent that's in a fling, not the child.
602-
rootApzc->AssertStateIsFling();
603-
childApzc->AssertStateIsReset();
604-
}
605-
606-
TEST_F(APZScrollHandoffTesterMock, ScrollgrabFlingAcceleration1) {
607-
SCOPED_GFX_PREF_BOOL("apz.allow_immediate_handoff", true);
608-
SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
609-
CreateScrollgrabLayerTree(true /* make parent scrollable */);
610-
611-
// Note: Usually, fling acceleration does not work across handoff, because our
612-
// fling acceleration code does not propagate the "fling cancel velocity"
613-
// across handoff. However, this test sets apz.fling_min_velocity_threshold to
614-
// zero, so the "fling cancel velocity" is allowed to be zero, and fling
615-
// acceleration succeeds, almost by accident.
616-
TestFlingAcceleration();
617-
}
618-
619-
TEST_F(APZScrollHandoffTesterMock, ScrollgrabFlingAcceleration2) {
620-
SCOPED_GFX_PREF_BOOL("apz.allow_immediate_handoff", true);
621-
SCOPED_GFX_PREF_FLOAT("apz.fling_min_velocity_threshold", 0.0f);
622-
CreateScrollgrabLayerTree(false /* do not make parent scrollable */);
623-
TestFlingAcceleration();
624-
}
625-
626509
TEST_F(APZScrollHandoffTester, ImmediateHandoffDisallowed_Pan) {
627510
SCOPED_GFX_PREF_BOOL("apz.allow_immediate_handoff", false);
628511

‎gfx/layers/ipc/LayersMessageUtils.h

-3
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ struct ParamTraits<mozilla::layers::ScrollMetadata>
599599
WriteParam(aWriter, aParam.mLineScrollAmount);
600600
WriteParam(aWriter, aParam.mPageScrollAmount);
601601
WriteParam(aWriter, aParam.mInteractiveWidget);
602-
WriteParam(aWriter, aParam.mHasScrollgrab);
603602
WriteParam(aWriter, aParam.mIsLayersIdRoot);
604603
WriteParam(aWriter, aParam.mIsAutoDirRootContentRTL);
605604
WriteParam(aWriter, aParam.mForceDisableApz);
@@ -634,8 +633,6 @@ struct ParamTraits<mozilla::layers::ScrollMetadata>
634633
ReadParam(aReader, &aResult->mLineScrollAmount) &&
635634
ReadParam(aReader, &aResult->mPageScrollAmount) &&
636635
ReadParam(aReader, &aResult->mInteractiveWidget) &&
637-
ReadBoolForBitfield(aReader, aResult,
638-
&paramType::SetHasScrollgrab) &&
639636
ReadBoolForBitfield(aReader, aResult,
640637
&paramType::SetIsLayersIdRoot) &&
641638
ReadBoolForBitfield(aReader, aResult,

‎layout/base/nsLayoutUtils.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -8931,14 +8931,6 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
89318931

89328932
metrics.SetPresShellId(presShell->GetPresShellId());
89338933

8934-
// If the scroll frame's content is marked 'scrollgrab', record this
8935-
// in the FrameMetrics so APZ knows to provide the scroll grabbing
8936-
// behaviour.
8937-
if (aScrollFrame &&
8938-
nsContentUtils::HasScrollgrab(aScrollFrame->GetContent())) {
8939-
metadata.SetHasScrollgrab(true);
8940-
}
8941-
89428934
if (ShouldDisableApzForElement(aContent)) {
89438935
metadata.SetForceDisableApz(true);
89448936
}

‎layout/generic/ScrollContainerFrame.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -4205,7 +4205,7 @@ void ScrollContainerFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
42054205
// minimal display port.
42064206
if (aBuilder->IsPaintingToWindow()) {
42074207
if (DisplayPortUtils::HasNonMinimalDisplayPort(GetContent()) ||
4208-
mZoomableByAPZ || nsContentUtils::HasScrollgrab(GetContent())) {
4208+
mZoomableByAPZ) {
42094209
aBuilder->SetContainsNonMinimalDisplayPort();
42104210
}
42114211
}
@@ -4537,9 +4537,7 @@ bool ScrollContainerFrame::DecideScrollableLayer(
45374537
// the compositor can find the scrollable layer for async scrolling.
45384538
// If the element is marked 'scrollgrab', also force building of a layer
45394539
// so that APZ can implement scroll grabbing.
4540-
mWillBuildScrollableLayer = hasDisplayPort ||
4541-
nsContentUtils::HasScrollgrab(content) ||
4542-
mZoomableByAPZ;
4540+
mWillBuildScrollableLayer = hasDisplayPort || mZoomableByAPZ;
45434541
return mWillBuildScrollableLayer;
45444542
}
45454543

@@ -5994,8 +5992,7 @@ bool ScrollContainerFrame::IsScrollingActive() const {
59945992

59955993
nsIContent* content = GetContent();
59965994
return mHasBeenScrolledRecently || IsAlwaysActive() ||
5997-
DisplayPortUtils::HasDisplayPort(content) ||
5998-
nsContentUtils::HasScrollgrab(content);
5995+
DisplayPortUtils::HasDisplayPort(content);
59995996
}
60005997

60015998
void ScrollContainerFrame::FinishReflowForScrollbar(

0 commit comments

Comments
 (0)
Failed to load comments.