Bug 1355376 - Do not use async scrollbar dragging for scroll frames with custom scrollbar mediators. r=mstange
Supporting custom scrollbar mediators would require having custom logic in APZ
for each custom mediator. Since custom mediators are only used by legacy XUL
elements (<listbox> and <tree>) that isn't worth implementing.
MozReview-Commit-ID: KtCUvtiR1qn
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -999,17 +999,18 @@ nsSliderFrame::StartAPZDrag(WidgetGUIEve
if (!aEvent->mFlags.mHandledByAPZ) {
return;
}
if (!gfxPlatform::GetPlatform()->SupportsApzDragInput()) {
return;
}
- nsContainerFrame* scrollFrame = GetScrollbar()->GetParent();
+ nsIFrame* scrollbarBox = GetScrollbar();
+ nsContainerFrame* scrollFrame = scrollbarBox->GetParent();
if (!scrollFrame) {
return;
}
nsIContent* scrollableContent = scrollFrame->GetContent();
if (!scrollableContent) {
return;
}
@@ -1020,25 +1021,38 @@ nsSliderFrame::StartAPZDrag(WidgetGUIEve
}
// APZ dragging requires the scrollbar to be layerized, which doesn't
// happen for scroll info layers.
if (ScrollFrameWillBuildScrollInfoLayer(scrollFrame)) {
return;
}
+ nsScrollbarFrame* scrollbarFrame = do_QueryFrame(scrollbarBox);
+ if (!scrollbarFrame) {
+ return;
+ }
+ if (nsIScrollbarMediator* mediator = scrollbarFrame->GetScrollbarMediator()) {
+ nsIScrollableFrame* scrollFrame = do_QueryFrame(mediator);
+ // The scrollbar mediator is not the scroll frame.
+ // That means this scroll frame has a custom scrollbar mediator.
+ // That's not supported in the APZ codepath.
+ if (!scrollFrame) {
+ return;
+ }
+ }
+
mozilla::layers::FrameMetrics::ViewID scrollTargetId;
bool hasID = nsLayoutUtils::FindIDFor(scrollableContent, &scrollTargetId);
bool hasAPZView = hasID && (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID);
if (!hasAPZView) {
return;
}
- nsIFrame* scrollbarBox = GetScrollbar();
nsCOMPtr<nsIContent> scrollbar = GetContentOfBox(scrollbarBox);
nsRect sliderTrack;
GetXULClientRect(sliderTrack);
// This rect is the range in which the scroll thumb can slide in.
sliderTrack = sliderTrack + GetRect().TopLeft() + scrollbarBox->GetPosition() -
scrollFrameAsScrollable->GetScrollPortRect().TopLeft();