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

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

Issue 1970763002: Fixed up root scroller API to be more webby (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sigh...fix test expectation again, fix crash when there's no renderer Created 4 years, 6 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 DCHECK(box); 235 DCHECK(box);
236 Node* node = box->node(); 236 Node* node = box->node();
237 237
238 // If there's no ApplyScroll callback on the element, scroll as usuall in 238 // If there's no ApplyScroll callback on the element, scroll as usuall in
239 // the non-scroll-customization case. 239 // the non-scroll-customization case.
240 if (!node || !node->isElementNode() || !toElement(node)->getApplyScroll()) { 240 if (!node || !node->isElementNode() || !toElement(node)->getApplyScroll()) {
241 *wasRootScroller = false; 241 *wasRootScroller = false;
242 return box->scroll(granularity, delta); 242 return box->scroll(granularity, delta);
243 } 243 }
244 244
245 // Viewport actions should only happen when scrolling an element in the
246 // main frame.
247 DCHECK(m_frame->isMainFrame());
248
249 // If there is an ApplyScroll callback, its because we placed one on the 245 // If there is an ApplyScroll callback, its because we placed one on the
250 // root scroller to control top controls and overscroll. Invoke a scroll 246 // root scroller to control top controls and overscroll. Invoke a scroll
251 // using parts of the scroll customization framework on just this element. 247 // using parts of the scroll customization framework on just this element.
252 computeScrollChainForSingleNode(*node, m_currentScrollChain); 248 computeScrollChainForSingleNode(*node, m_currentScrollChain);
253 249
254 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateData()); 250 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateData());
255 scrollStateData->delta_x = delta.width(); 251 scrollStateData->delta_x = delta.width();
256 scrollStateData->delta_y = delta.height(); 252 scrollStateData->delta_y = delta.height();
257 scrollStateData->position_x = position.x(); 253 scrollStateData->position_x = position.x();
258 scrollStateData->position_y = position.y(); 254 scrollStateData->position_y = position.y();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 if (!widget || !widget->isFrameView()) 481 if (!widget || !widget->isFrameView())
486 return WebInputEventResult::NotHandled; 482 return WebInputEventResult::NotHandled;
487 483
488 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent); 484 return toFrameView(widget)->frame().eventHandler().handleGestureScrollEvent( gestureEvent);
489 } 485 }
490 486
491 bool ScrollManager::isRootScroller(const Node& node) const 487 bool ScrollManager::isRootScroller(const Node& node) const
492 { 488 {
493 // The root scroller is the one Element on the page designated to perform 489 // The root scroller is the one Element on the page designated to perform
494 // "viewport actions" like top controls movement and overscroll glow. 490 // "viewport actions" like top controls movement and overscroll glow.
495 if (!frameHost() || !frameHost()->rootScroller()) 491 if (!m_frame->document())
496 return false; 492 return false;
497 493
498 return frameHost()->rootScroller()->get() == &node; 494 if (!node.isElementNode())
495 return false;
496
497 return m_frame->document()->topDocument().isEffectiveRootScroller(toElement( node));
499 } 498 }
500 499
501 500
502 WebInputEventResult ScrollManager::handleGestureScrollEvent(const PlatformGestur eEvent& gestureEvent) 501 WebInputEventResult ScrollManager::handleGestureScrollEvent(const PlatformGestur eEvent& gestureEvent)
503 { 502 {
504 Node* eventTarget = nullptr; 503 Node* eventTarget = nullptr;
505 Scrollbar* scrollbar = nullptr; 504 Scrollbar* scrollbar = nullptr;
506 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { 505 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) {
507 scrollbar = m_scrollbarHandlingScrollGesture.get(); 506 scrollbar = m_scrollbarHandlingScrollGesture.get();
508 eventTarget = m_scrollGestureHandlingNode.get(); 507 eventTarget = m_scrollGestureHandlingNode.get();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 DEFINE_TRACE(ScrollManager) 647 DEFINE_TRACE(ScrollManager)
649 { 648 {
650 visitor->trace(m_frame); 649 visitor->trace(m_frame);
651 visitor->trace(m_scrollGestureHandlingNode); 650 visitor->trace(m_scrollGestureHandlingNode);
652 visitor->trace(m_previousGestureScrolledNode); 651 visitor->trace(m_previousGestureScrolledNode);
653 visitor->trace(m_scrollbarHandlingScrollGesture); 652 visitor->trace(m_scrollbarHandlingScrollGesture);
654 visitor->trace(m_resizeScrollableArea); 653 visitor->trace(m_resizeScrollableArea);
655 } 654 }
656 655
657 } // namespace blink 656 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.h ('k') | third_party/WebKit/Source/core/page/scrolling/RootScroller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698