| 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/input/ScrollManager.h" | 5 #include "core/input/ScrollManager.h" |
| 6 | 6 |
| 7 #include "core/dom/DOMNodeIds.h" | 7 #include "core/dom/DOMNodeIds.h" |
| 8 #include "core/events/GestureEvent.h" | 8 #include "core/events/GestureEvent.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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 return &page->autoscrollController(); | 76 return &page->autoscrollController(); |
| 77 return nullptr; | 77 return nullptr; |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ScrollManager::recomputeScrollChain(const Node& startNode, | 80 void ScrollManager::recomputeScrollChain(const Node& startNode, |
| 81 std::deque<int>& scrollChain) { | 81 std::deque<int>& scrollChain) { |
| 82 scrollChain.clear(); | 82 scrollChain.clear(); |
| 83 | 83 |
| 84 DCHECK(startNode.layoutObject()); | 84 DCHECK(startNode.layoutObject()); |
| 85 LayoutBox* curBox = startNode.layoutObject()->enclosingBox(); | 85 LayoutBox* curBox = startNode.layoutObject()->enclosingBox(); |
| 86 Element* documentElement = m_frame->document()->documentElement(); |
| 86 | 87 |
| 87 // Scrolling propagates along the containing block chain and ends at the | 88 // Scrolling propagates along the containing block chain and ends at the |
| 88 // RootScroller element. The RootScroller element will have a custom | 89 // RootScroller element. The RootScroller element will have a custom |
| 89 // applyScroll callback that scrolls the frame or element. | 90 // applyScroll callback that scrolls the frame or element. |
| 90 while (curBox) { | 91 while (curBox) { |
| 91 Node* curNode = curBox->node(); | 92 Node* curNode = curBox->node(); |
| 92 Element* curElement = nullptr; | 93 Element* curElement = nullptr; |
| 93 | 94 |
| 94 // FIXME: this should reject more elements, as part of crbug.com/410974. | 95 // FIXME: this should reject more elements, as part of crbug.com/410974. |
| 95 if (curNode && curNode->isElementNode()) { | 96 if (curNode && curNode->isElementNode()) { |
| 96 curElement = toElement(curNode); | 97 curElement = toElement(curNode); |
| 97 } else if (curNode && curNode->isDocumentNode()) { | 98 } else if (curNode && curNode->isDocumentNode()) { |
| 98 // In normal circumastances, the documentElement will be the root | 99 // In normal circumastances, the documentElement will be the root |
| 99 // scroller but the documentElement itself isn't a containing block, | 100 // scroller but the documentElement itself isn't a containing block, |
| 100 // that'll be the document node rather than the element. | 101 // that'll be the document node rather than the element. |
| 101 curElement = m_frame->document()->documentElement(); | 102 curElement = documentElement; |
| 102 DCHECK(!curElement || isEffectiveRootScroller(*curElement)); | |
| 103 } | 103 } |
| 104 | 104 |
| 105 if (curElement) { | 105 if (curElement) { |
| 106 scrollChain.push_front(DOMNodeIds::idForNode(curElement)); | 106 scrollChain.push_front(DOMNodeIds::idForNode(curElement)); |
| 107 if (isEffectiveRootScroller(*curElement)) | 107 if (isEffectiveRootScroller(*curElement) || |
| 108 curElement->isSameNode(documentElement)) |
| 108 break; | 109 break; |
| 109 } | 110 } |
| 110 | 111 |
| 111 curBox = curBox->containingBlock(); | 112 curBox = curBox->containingBlock(); |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 | 115 |
| 115 bool ScrollManager::logicalScroll(ScrollDirection direction, | 116 bool ScrollManager::logicalScroll(ScrollDirection direction, |
| 116 ScrollGranularity granularity, | 117 ScrollGranularity granularity, |
| 117 Node* startNode, | 118 Node* startNode, |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 if (scrollbar->gestureEvent(targetedEvent.event(), &shouldUpdateCapture)) { | 533 if (scrollbar->gestureEvent(targetedEvent.event(), &shouldUpdateCapture)) { |
| 533 if (shouldUpdateCapture) | 534 if (shouldUpdateCapture) |
| 534 m_scrollbarHandlingScrollGesture = scrollbar; | 535 m_scrollbarHandlingScrollGesture = scrollbar; |
| 535 return true; | 536 return true; |
| 536 } | 537 } |
| 537 } | 538 } |
| 538 return false; | 539 return false; |
| 539 } | 540 } |
| 540 | 541 |
| 541 } // namespace blink | 542 } // namespace blink |
| OLD | NEW |