| 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/TopDocumentRootScrollerController.h" | 5 #include "core/page/scrolling/TopDocumentRootScrollerController.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/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // doesn't have a scrolling/clip layer, its PLC has a container layer that | 59 // doesn't have a scrolling/clip layer, its PLC has a container layer that |
| 60 // needs to be resized instead. | 60 // needs to be resized instead. |
| 61 layer->compositor()->frameViewDidChangeSize(); | 61 layer->compositor()->frameViewDidChangeSize(); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 ScrollableArea* TopDocumentRootScrollerController::rootScrollerArea() const { | 65 ScrollableArea* TopDocumentRootScrollerController::rootScrollerArea() const { |
| 66 return RootScrollerUtil::scrollableAreaForRootScroller(globalRootScroller()); | 66 return RootScrollerUtil::scrollableAreaForRootScroller(globalRootScroller()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 IntSize TopDocumentRootScrollerController::rootScrollerVisibleArea() const { | 69 IntRect TopDocumentRootScrollerController::visibleContentRect( |
| 70 IncludeScrollbarsInRect includeScrollbars) const { |
| 70 if (!topDocument() || !topDocument()->view()) | 71 if (!topDocument() || !topDocument()->view()) |
| 71 return IntSize(); | 72 return IntRect(); |
| 72 | 73 |
| 73 float minimumPageScale = | 74 float minimumPageScale = |
| 74 m_frameHost->pageScaleConstraintsSet().finalConstraints().minimumScale; | 75 m_frameHost->pageScaleConstraintsSet().finalConstraints().minimumScale; |
| 75 int browserControlsAdjustment = | 76 int browserControlsAdjustment = |
| 76 ceilf(m_frameHost->visualViewport().browserControlsAdjustment() / | 77 ceilf(m_frameHost->visualViewport().browserControlsAdjustment() / |
| 77 minimumPageScale); | 78 minimumPageScale); |
| 78 | 79 |
| 79 return topDocument()->view()->visibleContentSize(ExcludeScrollbars) + | 80 IntRect rect = topDocument()->view()->visibleContentRect(includeScrollbars); |
| 80 IntSize(0, browserControlsAdjustment); | 81 rect.expand(0, browserControlsAdjustment); |
| 82 |
| 83 return rect; |
| 84 } |
| 85 |
| 86 bool TopDocumentRootScrollerController::isRootScrollerAncestor( |
| 87 const Node& node) const { |
| 88 Node* curNode = globalRootScroller(); |
| 89 |
| 90 while (curNode) { |
| 91 if (node.isSameNode(curNode)) |
| 92 return true; |
| 93 |
| 94 // TODO(bokan): This won't work for OOPIF. crbug.com/642378. |
| 95 if (curNode->isDocumentNode()) |
| 96 curNode = toDocument(curNode)->localOwner(); |
| 97 else |
| 98 curNode = curNode->parentNode(); |
| 99 } |
| 100 |
| 101 return false; |
| 81 } | 102 } |
| 82 | 103 |
| 83 Element* TopDocumentRootScrollerController::findGlobalRootScrollerElement() { | 104 Element* TopDocumentRootScrollerController::findGlobalRootScrollerElement() { |
| 84 if (!topDocument()) | 105 if (!topDocument()) |
| 85 return nullptr; | 106 return nullptr; |
| 86 | 107 |
| 87 Node* effectiveRootScroller = | 108 Node* effectiveRootScroller = |
| 88 &topDocument()->rootScrollerController().effectiveRootScroller(); | 109 &topDocument()->rootScrollerController().effectiveRootScroller(); |
| 89 | 110 |
| 90 if (effectiveRootScroller->isDocumentNode()) | 111 if (effectiveRootScroller->isDocumentNode()) |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 278 |
| 258 PaintLayer* TopDocumentRootScrollerController::rootScrollerPaintLayer() const { | 279 PaintLayer* TopDocumentRootScrollerController::rootScrollerPaintLayer() const { |
| 259 return RootScrollerUtil::paintLayerForRootScroller(m_globalRootScroller); | 280 return RootScrollerUtil::paintLayerForRootScroller(m_globalRootScroller); |
| 260 } | 281 } |
| 261 | 282 |
| 262 Element* TopDocumentRootScrollerController::globalRootScroller() const { | 283 Element* TopDocumentRootScrollerController::globalRootScroller() const { |
| 263 return m_globalRootScroller.get(); | 284 return m_globalRootScroller.get(); |
| 264 } | 285 } |
| 265 | 286 |
| 266 } // namespace blink | 287 } // namespace blink |
| OLD | NEW |