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

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 1147283002: Add ScrollDirectionPhysical enum in Scroll types. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed a conflict on EventHandler Created 5 years, 7 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 | « Source/core/layout/LayoutEmbeddedObject.cpp ('k') | Source/platform/scroll/ScrollTypes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 node = m_frame->document()->focusedElement(); 556 node = m_frame->document()->focusedElement();
557 557
558 if (!node) 558 if (!node)
559 node = m_mousePressNode.get(); 559 node = m_mousePressNode.get();
560 560
561 if (!node || !node->layoutObject()) 561 if (!node || !node->layoutObject())
562 return false; 562 return false;
563 563
564 LayoutBox* curBox = node->layoutObject()->enclosingBox(); 564 LayoutBox* curBox = node->layoutObject()->enclosingBox();
565 while (curBox && !curBox->isLayoutView()) { 565 while (curBox && !curBox->isLayoutView()) {
566 ScrollDirection physicalDirection = toPhysicalDirection( 566 ScrollDirectionPhysical physicalDirection = toPhysicalDirection(
567 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode()); 567 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode());
568 568
569 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it 569 // If we're at the stopNode, we should try to scroll it but we shouldn't bubble past it
570 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode; 570 bool shouldStopBubbling = stopNode && *stopNode && curBox->node() == *st opNode;
571 bool didScroll = curBox->scroll(physicalDirection, granularity, delta); 571 bool didScroll = curBox->scroll(physicalDirection, granularity, delta);
572 572
573 if (didScroll && stopNode) 573 if (didScroll && stopNode)
574 *stopNode = curBox->node(); 574 *stopNode = curBox->node();
575 575
576 if (didScroll || shouldStopBubbling) { 576 if (didScroll || shouldStopBubbling) {
(...skipping 22 matching lines...) Expand all
599 { 599 {
600 // The layout needs to be up to date to determine if we can scroll. We may b e 600 // The layout needs to be up to date to determine if we can scroll. We may b e
601 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. 601 // here because of an onLoad event, in which case the final layout hasn't be en performed yet.
602 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 602 m_frame->document()->updateLayoutIgnorePendingStylesheets();
603 // FIXME: enable scroll customization in this case. See crbug.com/410974. 603 // FIXME: enable scroll customization in this case. See crbug.com/410974.
604 if (scroll(direction, granularity, startingNode)) 604 if (scroll(direction, granularity, startingNode))
605 return true; 605 return true;
606 LocalFrame* frame = m_frame; 606 LocalFrame* frame = m_frame;
607 FrameView* view = frame->view(); 607 FrameView* view = frame->view();
608 if (view) { 608 if (view) {
609 ScrollDirection physicalDirection = 609 ScrollDirectionPhysical physicalDirection =
610 toPhysicalDirection(direction, view->isVerticalDocument(), view->isF lippedDocument()); 610 toPhysicalDirection(direction, view->isVerticalDocument(), view->isF lippedDocument());
611 if (view->scrollableArea()->scroll(physicalDirection, granularity)) { 611 if (view->scrollableArea()->scroll(physicalDirection, granularity)) {
612 setFrameWasScrolledByUser(); 612 setFrameWasScrolledByUser();
613 return true; 613 return true;
614 } 614 }
615 } 615 }
616 616
617 Frame* parentFrame = frame->tree().parent(); 617 Frame* parentFrame = frame->tree().parent();
618 if (!parentFrame || !parentFrame->isLocalFrame()) 618 if (!parentFrame || !parentFrame->isLocalFrame())
619 return false; 619 return false;
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 1786
1787 Node* stopNode = m_previousWheelScrolledNode.get(); 1787 Node* stopNode = m_previousWheelScrolledNode.get();
1788 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt); 1788 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt);
1789 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation()); 1789 IntPoint absolutePosition = roundedIntPoint(wheelEvent->absoluteLocation());
1790 1790
1791 // Break up into two scrolls if we need to. Diagonal movement on 1791 // Break up into two scrolls if we need to. Diagonal movement on
1792 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set). 1792 // a MacBook pro is an example of a 2-dimensional mouse wheel event (where b oth deltaX and deltaY can be set).
1793 1793
1794 // FIXME: enable scroll customization in this case. See crbug.com/410974. 1794 // FIXME: enable scroll customization in this case. See crbug.com/410974.
1795 if (wheelEvent->railsMode() != Event::RailsModeVertical 1795 if (wheelEvent->railsMode() != Event::RailsModeVertical
1796 && scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->de ltaX(), absolutePosition)) 1796 && scroll(ScrollRightIgnoringWritingMode, granularity, startNode, &stopN ode, wheelEvent->deltaX(), absolutePosition))
1797 wheelEvent->setDefaultHandled(); 1797 wheelEvent->setDefaultHandled();
1798 1798
1799 if (wheelEvent->railsMode() != Event::RailsModeHorizontal 1799 if (wheelEvent->railsMode() != Event::RailsModeHorizontal
1800 && scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->del taY(), absolutePosition)) 1800 && scroll(ScrollDownIgnoringWritingMode, granularity, startNode, &stopNo de, wheelEvent->deltaY(), absolutePosition))
1801 wheelEvent->setDefaultHandled(); 1801 wheelEvent->setDefaultHandled();
1802 1802
1803 if (!m_latchedWheelEventNode) 1803 if (!m_latchedWheelEventNode)
1804 m_previousWheelScrolledNode = stopNode; 1804 m_previousWheelScrolledNode = stopNode;
1805 } 1805 }
1806 1806
1807 bool EventHandler::handleGestureShowPress() 1807 bool EventHandler::handleGestureShowPress()
1808 { 1808 {
1809 m_lastShowPressTimestamp = WTF::currentTime(); 1809 m_lastShowPressTimestamp = WTF::currentTime();
1810 1810
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); 2276 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement();
2277 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); 2277 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence();
2278 scrolled = scrollState->deltaX() != gestureEvent.deltaX() 2278 scrolled = scrollState->deltaX() != gestureEvent.deltaX()
2279 || scrollState->deltaY() != gestureEvent.deltaY(); 2279 || scrollState->deltaY() != gestureEvent.deltaY();
2280 } else { 2280 } else {
2281 if (gestureEvent.preventPropagation()) 2281 if (gestureEvent.preventPropagation())
2282 stopNode = m_previousGestureScrolledNode.get(); 2282 stopNode = m_previousGestureScrolledNode.get();
2283 2283
2284 // First try to scroll the closest scrollable LayoutBox ancestor of |node|. 2284 // First try to scroll the closest scrollable LayoutBox ancestor of |node|.
2285 ScrollGranularity granularity = ScrollByPrecisePixel; 2285 ScrollGranularity granularity = ScrollByPrecisePixel;
2286 bool horizontalScroll = scroll(ScrollLeft, granularity, node, &stopN ode, delta.width()); 2286 bool horizontalScroll = scroll(ScrollLeftIgnoringWritingMode, granul arity, node, &stopNode, delta.width());
2287 if (!gestureEvent.preventPropagation()) 2287 if (!gestureEvent.preventPropagation())
2288 stopNode = nullptr; 2288 stopNode = nullptr;
2289 bool verticalScroll = scroll(ScrollUp, granularity, node, &stopNode, delta.height()); 2289 bool verticalScroll = scroll(ScrollUpIgnoringWritingMode, granularit y, node, &stopNode, delta.height());
2290 scrolled = horizontalScroll || verticalScroll; 2290 scrolled = horizontalScroll || verticalScroll;
2291 2291
2292 if (gestureEvent.preventPropagation()) 2292 if (gestureEvent.preventPropagation())
2293 m_previousGestureScrolledNode = stopNode; 2293 m_previousGestureScrolledNode = stopNode;
2294 } 2294 }
2295 if (scrolled) { 2295 if (scrolled) {
2296 setFrameWasScrolledByUser(); 2296 setFrameWasScrolledByUser();
2297 return true; 2297 return true;
2298 } 2298 }
2299 } 2299 }
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
3210 // FIXME: enable scroll customization in this case. See crbug.com/410974. 3210 // FIXME: enable scroll customization in this case. See crbug.com/410974.
3211 if (scroll(direction, ScrollByPage)) { 3211 if (scroll(direction, ScrollByPage)) {
3212 event->setDefaultHandled(); 3212 event->setDefaultHandled();
3213 return; 3213 return;
3214 } 3214 }
3215 3215
3216 FrameView* view = m_frame->view(); 3216 FrameView* view = m_frame->view();
3217 if (!view) 3217 if (!view)
3218 return; 3218 return;
3219 3219
3220 ScrollDirection physicalDirection = 3220 ScrollDirectionPhysical physicalDirection =
3221 toPhysicalDirection(direction, view->isVerticalDocument(), view->isFlipp edDocument()); 3221 toPhysicalDirection(direction, view->isVerticalDocument(), view->isFlipp edDocument());
3222 3222
3223 if (view->scrollableArea()->scroll(physicalDirection, ScrollByPage)) 3223 if (view->scrollableArea()->scroll(physicalDirection, ScrollByPage))
3224 event->setDefaultHandled(); 3224 event->setDefaultHandled();
3225 } 3225 }
3226 3226
3227 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) 3227 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event)
3228 { 3228 {
3229 ASSERT(event->type() == EventTypeNames::keydown); 3229 ASSERT(event->type() == EventTypeNames::keydown);
3230 3230
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
3725 unsigned EventHandler::accessKeyModifiers() 3725 unsigned EventHandler::accessKeyModifiers()
3726 { 3726 {
3727 #if OS(MACOSX) 3727 #if OS(MACOSX)
3728 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3728 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3729 #else 3729 #else
3730 return PlatformEvent::AltKey; 3730 return PlatformEvent::AltKey;
3731 #endif 3731 #endif
3732 } 3732 }
3733 3733
3734 } // namespace blink 3734 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutEmbeddedObject.cpp ('k') | Source/platform/scroll/ScrollTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698