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