Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Unified Diff: third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp

Issue 2728253002: Remove indirection: setup scrollbar scroll layers in the scrollbar constructor (Closed)
Patch Set: Really fix reivewer comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
diff --git a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
index 970e26a12dd3a76062c2a489a7c45ecbf0bbde5c..55967dcecf10982defa3dcdc4920bf1a23ca3aa1 100644
--- a/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
+++ b/third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -339,7 +339,8 @@ void ScrollingCoordinator::removeWebScrollbarLayer(
static std::unique_ptr<WebScrollbarLayer> createScrollbarLayer(
Scrollbar& scrollbar,
- float deviceScaleFactor) {
+ float deviceScaleFactor,
+ WebLayer* scrollLayer) {
ScrollbarTheme& theme = scrollbar.theme();
WebScrollbarThemePainter painter(theme, scrollbar, deviceScaleFactor);
std::unique_ptr<WebScrollbarThemeGeometry> geometry(
@@ -349,11 +350,13 @@ static std::unique_ptr<WebScrollbarLayer> createScrollbarLayer(
if (theme.usesOverlayScrollbars() && theme.usesNinePatchThumbResource()) {
scrollbarLayer =
Platform::current()->compositorSupport()->createOverlayScrollbarLayer(
- WebScrollbarImpl::create(&scrollbar), painter, std::move(geometry));
+ WebScrollbarImpl::create(&scrollbar), painter, std::move(geometry),
+ scrollLayer);
} else {
scrollbarLayer =
Platform::current()->compositorSupport()->createScrollbarLayer(
- WebScrollbarImpl::create(&scrollbar), painter, std::move(geometry));
+ WebScrollbarImpl::create(&scrollbar), painter, std::move(geometry),
+ scrollLayer);
}
GraphicsLayer::registerContentsLayer(scrollbarLayer->layer());
return scrollbarLayer;
@@ -364,14 +367,15 @@ ScrollingCoordinator::createSolidColorScrollbarLayer(
ScrollbarOrientation orientation,
int thumbThickness,
int trackStart,
- bool isLeftSideVerticalScrollbar) {
+ bool isLeftSideVerticalScrollbar,
+ WebLayer* scrollLayer) {
WebScrollbar::Orientation webOrientation =
(orientation == HorizontalScrollbar) ? WebScrollbar::Horizontal
: WebScrollbar::Vertical;
std::unique_ptr<WebScrollbarLayer> scrollbarLayer =
Platform::current()->compositorSupport()->createSolidColorScrollbarLayer(
webOrientation, thumbThickness, trackStart,
- isLeftSideVerticalScrollbar);
+ isLeftSideVerticalScrollbar, scrollLayer);
GraphicsLayer::registerContentsLayer(scrollbarLayer->layer());
return scrollbarLayer;
}
@@ -393,7 +397,6 @@ static void setupScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer,
detachScrollbarLayer(scrollbarGraphicsLayer);
return;
}
- scrollbarLayer->setScrollLayer(scrollLayer);
scrollbarGraphicsLayer->setContentsToPlatformLayer(scrollbarLayer->layer());
scrollbarGraphicsLayer->setDrawsContent(false);
}
@@ -445,6 +448,13 @@ void ScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(
// scrollbar becomes a non-custom one.
scrollbarGraphicsLayer->platformLayer()->clearMainThreadScrollingReasons(
MainThreadScrollingReason::kCustomScrollbarScrolling);
+
+ WebLayer* scrollLayer = toWebLayer(scrollableArea->layerForScrolling());
+ if (!scrollLayer) {
+ detachScrollbarLayer(scrollbarGraphicsLayer);
+ return;
+ }
+
WebScrollbarLayer* scrollbarLayer =
getWebScrollbarLayer(scrollableArea, orientation);
if (!scrollbarLayer) {
@@ -456,16 +466,15 @@ void ScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(
webScrollbarLayer = createSolidColorScrollbarLayer(
orientation, scrollbar.theme().thumbThickness(scrollbar),
scrollbar.theme().trackPosition(scrollbar),
- scrollableArea->shouldPlaceVerticalScrollbarOnLeft());
+ scrollableArea->shouldPlaceVerticalScrollbarOnLeft(), scrollLayer);
} else {
webScrollbarLayer = createScrollbarLayer(
- scrollbar, m_page->deviceScaleFactorDeprecated());
+ scrollbar, m_page->deviceScaleFactorDeprecated(), scrollLayer);
}
scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation,
std::move(webScrollbarLayer));
}
- WebLayer* scrollLayer = toWebLayer(scrollableArea->layerForScrolling());
setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollLayer);
// Root layer non-overlay scrollbars should be marked opaque to disable

Powered by Google App Engine
This is Rietveld 408576698