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

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: Rebase and remove hack Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/scrolling/scroll-non-descendant-of-root-scroller.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 &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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 if (scrollbar->gestureEvent(targetedEvent.event(), &shouldUpdateCapture)) { 535 if (scrollbar->gestureEvent(targetedEvent.event(), &shouldUpdateCapture)) {
535 if (shouldUpdateCapture) 536 if (shouldUpdateCapture)
536 m_scrollbarHandlingScrollGesture = scrollbar; 537 m_scrollbarHandlingScrollGesture = scrollbar;
537 return true; 538 return true;
538 } 539 }
539 } 540 }
540 return false; 541 return false;
541 } 542 }
542 543
543 } // namespace blink 544 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/scrolling/scroll-non-descendant-of-root-scroller.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698