Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: third_party/WebKit/Source/core/input/ScrollManager.cpp

Issue 2365793002: Fix scroll chaining for non-descendants of root scroller. (Closed)
Patch Set: Fix tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
76 return nullptr; 76 return nullptr;
77 } 77 }
78 78
79 void ScrollManager::recomputeScrollChain(const Node& startNode, 79 void ScrollManager::recomputeScrollChain(const Node& startNode,
80 std::deque<int>& scrollChain) 80 std::deque<int>& scrollChain)
81 { 81 {
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, ScrollGranularity g ranularity, Node* startNode, Node* mousePressNode) 116 bool ScrollManager::logicalScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startNode, Node* mousePressNode)
116 { 117 {
117 Node* node = startNode; 118 Node* node = startNode;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 DEFINE_TRACE(ScrollManager) 507 DEFINE_TRACE(ScrollManager)
507 { 508 {
508 visitor->trace(m_frame); 509 visitor->trace(m_frame);
509 visitor->trace(m_scrollGestureHandlingNode); 510 visitor->trace(m_scrollGestureHandlingNode);
510 visitor->trace(m_previousGestureScrolledNode); 511 visitor->trace(m_previousGestureScrolledNode);
511 visitor->trace(m_scrollbarHandlingScrollGesture); 512 visitor->trace(m_scrollbarHandlingScrollGesture);
512 visitor->trace(m_resizeScrollableArea); 513 visitor->trace(m_resizeScrollableArea);
513 } 514 }
514 515
515 } // namespace blink 516 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698