Index: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
index f4d15b2eedadc3050bed99b495cc9f3bc1f32b17..742a651142649cf011455bdb5dbd3840902678ca 100644 |
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp |
@@ -71,7 +71,9 @@ |
#include "core/page/FocusController.h" |
#include "core/page/Page.h" |
#include "core/page/scrolling/RootScrollerController.h" |
+#include "core/page/scrolling/RootScrollerUtil.h" |
#include "core/page/scrolling/ScrollingCoordinator.h" |
+#include "core/page/scrolling/TopDocumentRootScrollerController.h" |
#include "core/paint/PaintLayerFragment.h" |
#include "platform/PlatformGestureEvent.h" |
#include "platform/PlatformMouseEvent.h" |
@@ -805,6 +807,22 @@ void PaintLayerScrollableArea::clampScrollOffsetsAfterLayout() { |
m_scrollbarManager.destroyDetachedScrollbars(); |
} |
+void PaintLayerScrollableArea::didChangeGlobalRootScroller() { |
+ // On Android, where the VisualViewport supplies scrollbars, we need to |
+ // remove the PLSA's scrollbars. In general, this would be problematic as |
+ // that can cause layout but this should only ever apply with overlay |
+ // scrollbars. |
+ if (!box().frame()->settings() || |
+ !box().frame()->settings()->viewportEnabled()) |
+ return; |
+ |
+ bool needsHorizontalScrollbar; |
+ bool needsVerticalScrollbar; |
+ computeScrollbarExistence(needsHorizontalScrollbar, needsVerticalScrollbar); |
+ setHasHorizontalScrollbar(needsHorizontalScrollbar); |
+ setHasVerticalScrollbar(needsVerticalScrollbar); |
+} |
+ |
bool PaintLayerScrollableArea::shouldPerformScrollAnchoring() const { |
return RuntimeEnabledFeatures::scrollAnchoringEnabled() && |
m_scrollAnchor.hasScroller() && |
@@ -1728,14 +1746,22 @@ void PaintLayerScrollableArea::setTopmostScrollChild(PaintLayer* scrollChild) { |
} |
bool PaintLayerScrollableArea::visualViewportSuppliesScrollbars() const { |
- if (!layer()->isRootLayer()) |
+ LocalFrame* frame = box().frame(); |
+ if (!frame || !frame->settings()) |
return false; |
- LocalFrame* frame = box().frame(); |
- if (!frame || !frame->isMainFrame() || !frame->settings()) |
+ // On desktop, we always use the layout viewport's scrollbars. |
+ if (!frame->settings()->viewportEnabled()) |
+ return false; |
+ |
+ const TopDocumentRootScrollerController& controller = |
+ layoutBox()->document().frameHost()->globalRootScrollerController(); |
+ |
+ if (!controller.globalRootScroller()) |
return false; |
- return frame->settings()->viewportEnabled(); |
+ return RootScrollerUtil::scrollableAreaFor( |
+ *controller.globalRootScroller()) == this; |
} |
Widget* PaintLayerScrollableArea::getWidget() { |