OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/page/scrolling/RootScrollerUtil.h" |
| 6 |
| 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/Element.h" |
| 9 #include "core/frame/FrameView.h" |
| 10 #include "core/layout/LayoutBox.h" |
| 11 #include "core/layout/LayoutObject.h" |
| 12 #include "core/paint/PaintLayerScrollableArea.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 namespace RootScrollerUtil { |
| 17 |
| 18 ScrollableArea* scrollableAreaFor(const Element& element) |
| 19 { |
| 20 if (!element.layoutObject() || !element.layoutObject()->isBox()) |
| 21 return nullptr; |
| 22 |
| 23 LayoutBox* box = toLayoutBox(element.layoutObject()); |
| 24 |
| 25 // For a FrameView, we use the layoutViewport rather than the |
| 26 // getScrollableArea() since that could be the RootFrameViewport. The |
| 27 // rootScroller's ScrollableArea will be swapped in as the layout viewport |
| 28 // in RootFrameViewport so we need to ensure we get the layout viewport. |
| 29 if (box->isDocumentElement()) |
| 30 return element.document().view()->layoutViewportScrollableArea(); |
| 31 |
| 32 return static_cast<PaintInvalidationCapableScrollableArea*>( |
| 33 box->getScrollableArea()); |
| 34 } |
| 35 |
| 36 } // namespace RootScrollerUtil |
| 37 |
| 38 } // namespace blink |
OLD | NEW |