Chromium Code Reviews| Index: Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
| diff --git a/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp b/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
| index c173c3fc7e6770de1079590803f222c11f6c0d5b..e063ed0909cb26b7c104a8249cebe2c4b375eda6 100644 |
| --- a/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
| +++ b/Source/core/paint/DeprecatedPaintLayerScrollableArea.cpp |
| @@ -55,6 +55,7 @@ |
| #include "core/html/HTMLFrameOwnerElement.h" |
| #include "core/input/EventHandler.h" |
| #include "core/layout/LayoutGeometryMap.h" |
| +#include "core/layout/LayoutPart.h" |
| #include "core/layout/LayoutScrollbar.h" |
| #include "core/layout/LayoutScrollbarPart.h" |
| #include "core/layout/LayoutTheme.h" |
| @@ -924,9 +925,32 @@ IntSize DeprecatedPaintLayerScrollableArea::scrollbarOffset(const Scrollbar* scr |
| static inline LayoutObject* layoutObjectForScrollbar(LayoutObject& layoutObject) |
| { |
| if (Node* node = layoutObject.node()) { |
| - if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { |
| - if (shadowRoot->type() == ShadowRootType::UserAgent) |
| - return shadowRoot->host()->layoutObject(); |
| + if (layoutObject.isLayoutView()) { |
| + Document* doc = &node->document(); |
|
skobes
2015/08/12 01:59:25
Since Node::document() returns a reference, let's
MuVen
2015/08/12 07:15:09
Done.
|
| + if (Settings* settings = doc->settings()) { |
| + if (!settings->allowCustomScrollbarInMainFrame() && layoutObject.frame() && layoutObject.frame()->isMainFrame()) |
| + return &layoutObject; |
| + } |
| + |
| + // Try the <body> element first as a scrollbar source. |
| + Element* body = doc ? doc->body() : 0; |
| + if (body && body->layoutObject() && body->layoutObject()->style()->hasPseudoStyle(SCROLLBAR)) |
| + return body->layoutObject(); |
| + |
| + // If the <body> didn't have a custom style, then the root element might. |
| + Element* docElement = doc ? doc->documentElement() : 0; |
| + if (docElement && docElement->layoutObject() && docElement->layoutObject()->style()->hasPseudoStyle(SCROLLBAR)) |
| + return docElement->layoutObject(); |
| + |
| + // If we have an owning ipage/LocalFrame element, then it can set the custom scrollbar also. |
| + LayoutPart* frameLayoutObject = node->document().frame()->ownerLayoutObject(); |
| + if (frameLayoutObject && frameLayoutObject->style()->hasPseudoStyle(SCROLLBAR)) |
| + return frameLayoutObject; |
| + |
| + if (ShadowRoot* shadowRoot = node->containingShadowRoot()) { |
|
skobes
2015/08/12 01:59:25
This part should remain outside the LayoutView cas
MuVen
2015/08/12 07:15:09
Done.
|
| + if (shadowRoot->type() == ShadowRootType::UserAgent) |
| + return shadowRoot->host()->layoutObject(); |
| + } |
| } |
| } |