Chromium Code Reviews| Index: third_party/WebKit/Source/core/page/scrolling/RootScrollerUtil.cpp |
| diff --git a/third_party/WebKit/Source/core/page/scrolling/RootScrollerUtil.cpp b/third_party/WebKit/Source/core/page/scrolling/RootScrollerUtil.cpp |
| index 4940df7bb9d775466499d6dbfeb1b5966f1e3027..6f7adfcbfd48620ceaf28af3882886c2468271ab 100644 |
| --- a/third_party/WebKit/Source/core/page/scrolling/RootScrollerUtil.cpp |
| +++ b/third_party/WebKit/Source/core/page/scrolling/RootScrollerUtil.cpp |
| @@ -7,7 +7,10 @@ |
| #include "core/dom/Document.h" |
| #include "core/dom/Element.h" |
| #include "core/frame/FrameView.h" |
| +#include "core/layout/LayoutBox.h" |
| #include "core/layout/LayoutBoxModelObject.h" |
| +#include "core/layout/compositing/PaintLayerCompositor.h" |
| +#include "core/paint/PaintLayer.h" |
| #include "core/paint/PaintLayerScrollableArea.h" |
| namespace blink { |
| @@ -33,6 +36,27 @@ ScrollableArea* scrollableAreaFor(const Element& element) { |
| toLayoutBoxModelObject(element.layoutObject())->getScrollableArea()); |
| } |
| +PaintLayer* paintLayerFor(const Element* element) { |
| + if (!element || !element->layoutObject() || !element->layoutObject()->isBox()) |
|
chrishtr
2016/11/18 00:37:09
Is it possible for it to be a non-box, or is this
bokan
2016/11/18 22:30:35
If an element is the root scroller it must be a bo
|
| + return nullptr; |
| + |
| + LayoutBox* box = toLayoutBox(element->layoutObject()); |
| + PaintLayer* layer = box->layer(); |
|
chrishtr
2016/11/18 00:37:09
DCHECK(layer);
bokan
2016/11/18 22:30:35
It's now just used for return.
|
| + |
| + // If the root scroller is the <html> element we do a bit of a fake out |
| + // because while <html> has a PaintLayer, scrolling for it is handled by the |
| + // #document's PaintLayer (i.e. the PaintLayerCompositor's root layer). The |
| + // reason the root scroller is the <html> layer and not #document is because |
| + // the latter is a Node but not an Element. |
| + if (element->isSameNode(element->document().documentElement())) { |
| + if (!layer || !layer->compositor()) |
| + return nullptr; |
| + return layer->compositor()->rootLayer(); |
|
chrishtr
2016/11/18 00:37:09
I prefer:
return box->view()->layer()
bokan
2016/11/18 22:30:35
Done.
|
| + } |
| + |
| + return layer; |
| +} |
| + |
| } // namespace RootScrollerUtil |
| } // namespace blink |