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

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

Issue 1752043002: Merged FrameView and LayoutBox scrolling in EventHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@invertScrollCustomizationPath
Patch Set: Created 4 years, 9 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 /* 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 593
594 return result; 594 return result;
595 } 595 }
596 596
597 void EventHandler::stopAutoscroll() 597 void EventHandler::stopAutoscroll()
598 { 598 {
599 if (AutoscrollController* controller = autoscrollController()) 599 if (AutoscrollController* controller = autoscrollController())
600 controller->stopAutoscroll(); 600 controller->stopAutoscroll();
601 } 601 }
602 602
603 ScrollResult EventHandler::physicalScroll(ScrollGranularity granularity, const F loatSize& delta, Node* startNode, Node** stopNode) 603 ScrollResult EventHandler::physicalScroll(ScrollGranularity granularity, const F loatSize& delta, Node* startNode, Node** stopNode, bool& consumed)
tdresser 2016/03/01 21:57:40 Would it be better to include this as part of the
bokan 2016/03/01 22:09:39 I tried that at first but it got ambiguous in a nu
tdresser 2016/03/02 14:27:20 Acknowledged.
604 { 604 {
605 consumed = false;
605 if (delta.isZero()) 606 if (delta.isZero())
606 return ScrollResult(); 607 return ScrollResult();
607 608
608 Node* node = startNode; 609 Node* node = startNode;
609 ASSERT(node && node->layoutObject()); 610 ASSERT(node && node->layoutObject());
610 611
611 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 612 m_frame->document()->updateLayoutIgnorePendingStylesheets();
612 613
613 ScrollResult result; 614 ScrollResult result;
614 615
615 LayoutBox* curBox = node->layoutObject()->enclosingBox(); 616 LayoutBox* curBox = node->layoutObject()->enclosingBox();
616 while (curBox && !curBox->isLayoutView()) { 617 while (curBox) {
617 // If we're at the stopNode, we should try to scroll it but we shouldn't 618 // If we're at the stopNode, we should try to scroll it but we shouldn't
618 // chain past it. 619 // chain past it.
619 bool shouldStopChaining = 620 bool shouldStopChaining =
620 stopNode && *stopNode && curBox->node() == *stopNode; 621 stopNode && *stopNode && curBox->node() == *stopNode;
621 result = curBox->scroll(granularity, delta); 622 result = curBox->scroll(granularity, delta);
622 623
623 if (result.didScroll() && stopNode) 624 if (result.didScroll() && stopNode)
624 *stopNode = curBox->node(); 625 *stopNode = curBox->node();
625 626
626 if (result.didScroll() || shouldStopChaining) { 627 if (result.didScroll() || shouldStopChaining) {
627 setFrameWasScrolledByUser(); 628 setFrameWasScrolledByUser();
628 if (!result.didScroll()) { 629 consumed = true;
629 // TODO(bokan): We should probably add a "shouldPropagate" bit
630 // on the result rather than lying to the caller.
631 result.didScrollX = true;
632 result.didScrollY = true;
633 }
634 return result; 630 return result;
635 } 631 }
636 632
637 curBox = curBox->containingBlock(); 633 curBox = curBox->isLayoutView() ? nullptr : curBox->containingBlock();
szager1 2016/03/02 19:14:34 Is is necessary to special-case LayoutView here?
bokan 2016/03/02 20:37:13 Ah, I thought it was since I assumed containingBlo
638 } 634 }
639 635
640 return result; 636 return result;
641 } 637 }
642 638
643 bool EventHandler::logicalScroll(ScrollDirection direction, ScrollGranularity gr anularity, Node* startNode) 639 bool EventHandler::logicalScroll(ScrollDirection direction, ScrollGranularity gr anularity, Node* startNode)
644 { 640 {
645 Node* node = startNode; 641 Node* node = startNode;
646 642
647 if (!node) 643 if (!node)
648 node = m_frame->document()->focusedElement(); 644 node = m_frame->document()->focusedElement();
649 645
650 if (!node) 646 if (!node)
651 node = m_mousePressNode.get(); 647 node = m_mousePressNode.get();
652 648
653 if (!node || !node->layoutObject()) 649 if (!node || !node->layoutObject())
654 return false; 650 return false;
655 651
656 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 652 m_frame->document()->updateLayoutIgnorePendingStylesheets();
657 653
658 LayoutBox* curBox = node->layoutObject()->enclosingBox(); 654 LayoutBox* curBox = node->layoutObject()->enclosingBox();
659 while (curBox && !curBox->isLayoutView()) { 655 while (curBox) {
660 ScrollDirectionPhysical physicalDirection = toPhysicalDirection( 656 ScrollDirectionPhysical physicalDirection = toPhysicalDirection(
661 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode()); 657 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode());
662 658
663 ScrollResult result = curBox->scroll(granularity, toScrollDelta(physical Direction, 1)); 659 ScrollResult result = curBox->scroll(granularity, toScrollDelta(physical Direction, 1));
664 660
665 if (result.didScroll()) { 661 if (result.didScroll()) {
666 setFrameWasScrolledByUser(); 662 setFrameWasScrolledByUser();
667 return true; 663 return true;
668 } 664 }
669 665
670 curBox = curBox->containingBlock(); 666 curBox = curBox->isLayoutView() ? nullptr : curBox->containingBlock();
szager1 2016/03/02 19:14:34 ditto
bokan 2016/03/02 20:37:13 Acknowledged.
671 } 667 }
672 668
673 return false; 669 return false;
674 } 670 }
675 671
676 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt ate) 672 void EventHandler::customizedScroll(const Node& startNode, ScrollState& scrollSt ate)
677 { 673 {
678 if (scrollState.fullyConsumed()) 674 if (scrollState.fullyConsumed())
679 return; 675 return;
680 676
(...skipping 10 matching lines...) Expand all
691 // TODO(bokan): This should be merged with logicalScroll assuming 687 // TODO(bokan): This should be merged with logicalScroll assuming
692 // defaultSpaceEventHandler's chaining scroll can be done crossing frames. 688 // defaultSpaceEventHandler's chaining scroll can be done crossing frames.
693 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) 689 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode)
694 { 690 {
695 // The layout needs to be up to date to determine if we can scroll. We may b e 691 // The layout needs to be up to date to determine if we can scroll. We may b e
696 // here because of an onLoad event, in which case the final layout hasn't be en performed yet. 692 // here because of an onLoad event, in which case the final layout hasn't be en performed yet.
697 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 693 m_frame->document()->updateLayoutIgnorePendingStylesheets();
698 // FIXME: enable scroll customization in this case. See crbug.com/410974. 694 // FIXME: enable scroll customization in this case. See crbug.com/410974.
699 if (logicalScroll(direction, granularity, startingNode)) 695 if (logicalScroll(direction, granularity, startingNode))
700 return true; 696 return true;
701 LocalFrame* frame = m_frame;
702 FrameView* view = frame->view();
703 if (view) {
704 ScrollDirectionPhysical physicalDirection =
705 toPhysicalDirection(direction, view->isVerticalDocument(), view->isF lippedDocument());
706 if (view->scrollableArea()->userScroll(granularity, toScrollDelta(physic alDirection, 1)).didScroll()) {
707 setFrameWasScrolledByUser();
708 return true;
709 }
710 }
711 697
712 Frame* parentFrame = frame->tree().parent(); 698 Frame* parentFrame = m_frame->tree().parent();
713 if (!parentFrame || !parentFrame->isLocalFrame()) 699 if (!parentFrame || !parentFrame->isLocalFrame())
714 return false; 700 return false;
715 // FIXME: Broken for OOPI. 701 // FIXME: Broken for OOPI.
716 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner()); 702 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner());
717 } 703 }
718 704
719 IntPoint EventHandler::lastKnownMousePosition() const 705 IntPoint EventHandler::lastKnownMousePosition() const
720 { 706 {
721 return m_lastKnownMousePosition; 707 return m_lastKnownMousePosition;
722 } 708 }
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 Element* found = page->focusController().findFocusableElementInShadowHos t(element); 1742 Element* found = page->focusController().findFocusableElementInShadowHos t(element);
1757 if (found && element.containsIncludingShadowDOM(found)) { 1743 if (found && element.containsIncludingShadowDOM(found)) {
1758 // Use WebFocusTypeForward instead of WebFocusTypeMouse here to mean the focus has slided. 1744 // Use WebFocusTypeForward instead of WebFocusTypeMouse here to mean the focus has slided.
1759 found->focus(FocusParams(SelectionBehaviorOnFocus::Reset, WebFocusTy peForward, nullptr)); 1745 found->focus(FocusParams(SelectionBehaviorOnFocus::Reset, WebFocusTy peForward, nullptr));
1760 return true; 1746 return true;
1761 } 1747 }
1762 } 1748 }
1763 return false; 1749 return false;
1764 } 1750 }
1765 1751
1766 namespace {
1767
1768 ScrollResult scrollAreaWithWheelEvent(const PlatformWheelEvent& event, Scrollabl eArea& scrollableArea)
1769 {
1770 float deltaX = event.getRailsMode() != PlatformEvent::RailsModeVertical ? ev ent.deltaX() : 0;
1771 float deltaY = event.getRailsMode() != PlatformEvent::RailsModeHorizontal ? event.deltaY() : 0;
1772
1773 ScrollGranularity granularity =
1774 event.granularity() == ScrollByPixelWheelEvent ? ScrollByPixel : ScrollB yPage;
1775
1776 if (event.hasPreciseScrollingDeltas() && granularity == ScrollByPixel)
1777 granularity = ScrollByPrecisePixel;
1778
1779 // If the event is a "PageWheelEvent" we should disregard the delta and
1780 // scroll by *one* page length per event.
1781 if (event.granularity() == ScrollByPageWheelEvent) {
1782 if (deltaX)
1783 deltaX = deltaX > 0 ? 1 : -1;
1784 if (deltaY)
1785 deltaY = deltaY > 0 ? 1 : -1;
tdresser 2016/03/01 21:57:40 I think this logic is so that we never coalesce pa
bokan 2016/03/01 22:09:39 Ah, could we ensure this is enforced at coalescing
tdresser 2016/03/02 14:27:20 Moving this to https://code.google.com/p/chromium/
1786 }
1787
1788 // On a wheel event, positive delta is meant to scroll up and left, which
1789 // is the opposite of deltas in the scrolling system.
1790 return scrollableArea.userScroll(granularity, FloatSize(-deltaX, -deltaY));
1791 }
1792
1793 } // namespace
1794
1795 WebInputEventResult EventHandler::handleWheelEvent(const PlatformWheelEvent& eve nt) 1752 WebInputEventResult EventHandler::handleWheelEvent(const PlatformWheelEvent& eve nt)
1796 { 1753 {
1797 Document* doc = m_frame->document(); 1754 Document* doc = m_frame->document();
1798 1755
1799 if (!doc->layoutView()) 1756 if (!doc->layoutView())
1800 return WebInputEventResult::NotHandled; 1757 return WebInputEventResult::NotHandled;
1801 1758
1802 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); 1759 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view());
1803 1760
1804 FrameView* view = m_frame->view(); 1761 FrameView* view = m_frame->view();
(...skipping 29 matching lines...) Expand all
1834 1791
1835 if (node && sendDOMEvent) { 1792 if (node && sendDOMEvent) {
1836 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow()); 1793 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow());
1837 DispatchEventResult domEventResult = node->dispatchEvent(domEvent); 1794 DispatchEventResult domEventResult = node->dispatchEvent(domEvent);
1838 if (domEventResult != DispatchEventResult::NotCanceled) { 1795 if (domEventResult != DispatchEventResult::NotCanceled) {
1839 setFrameWasScrolledByUser(); 1796 setFrameWasScrolledByUser();
1840 return toWebInputEventResult(domEventResult); 1797 return toWebInputEventResult(domEventResult);
1841 } 1798 }
1842 } 1799 }
1843 1800
1844 // We do another check on the frame view because the event handler can run
1845 // JS which results in the frame getting destroyed.
1846 view = m_frame->view();
1847 if (!view)
1848 return WebInputEventResult::NotHandled;
1849
1850 // Wheel events which do not scroll are used to trigger zooming.
1851 if (!event.canScroll())
1852 return WebInputEventResult::NotHandled;
1853
1854 ScrollResult scrollResult = scrollAreaWithWheelEvent(event, *view->scrollabl eArea());
1855 if (m_frame->isMainFrame() && m_frame->settings() && m_frame->settings()->re portWheelOverscroll())
1856 handleOverscroll(scrollResult);
1857 if (scrollResult.didScroll()) {
1858 setFrameWasScrolledByUser();
1859 return WebInputEventResult::HandledSystem;
1860 }
1861
1862 return WebInputEventResult::NotHandled; 1801 return WebInputEventResult::NotHandled;
1863 } 1802 }
1864 1803
1865 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) 1804 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent)
1866 { 1805 {
1867 if (!startNode || !wheelEvent) 1806 if (!startNode || !wheelEvent)
1868 return; 1807 return;
1869 1808
1870 // When the wheelEvent do not scroll, we trigger zoom in/out instead. 1809 // When the wheelEvent do not scroll, we trigger zoom in/out instead.
1871 if (!wheelEvent->canScroll()) 1810 if (!wheelEvent->canScroll())
1872 return; 1811 return;
1873 1812
1874 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt); 1813 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt);
1875 Node* node = nullptr; 1814 Node* node = nullptr;
1876 1815
1816 // TODO(bokan): Previously, the code for scrolling a view from
1817 // handleWheelEvent would clamp deltas to -1/1 for non-pixel scrolls, which
1818 // is inconsistent with how the rest of the layout tree is scrolled (non-1
1819 // deltas are allowed on non-pixel scrolls). We can probably just remove
1820 // this ASSERT if its not firing. Otherwise add back in the clamping.
1821 ASSERT((granularity == ScrollByPixel || granularity == ScrollByPrecisePixel)
bokan 2016/03/01 19:49:25 Alternatively, we can just remove this ASSERT and
tdresser 2016/03/01 21:57:40 This should check if the granularity is page based
tdresser 2016/03/01 21:57:40 ASSERT seems reasonable to me.
bokan 2016/03/01 22:09:39 Right now, this check is making sure that only Pix
bokan 2016/03/01 22:09:39 Acknowledged.
tdresser 2016/03/02 14:27:20 Oops, the assert should fire if we coalesce page s
bokan 2016/03/02 20:37:13 Ok, I've removed the ASSERT here and reinstated th
1822 || (std::abs(wheelEvent->deltaX()) == 1 || !wheelEvent->deltaX()
1823 && std::abs(wheelEvent->deltaY()) == 1 || !wheelEvent->deltaY()));
1824
1877 // Diagonal movement on a MacBook pro is an example of a 2-dimensional 1825 // Diagonal movement on a MacBook pro is an example of a 2-dimensional
1878 // mouse wheel event (where both deltaX and deltaY can be set). 1826 // mouse wheel event (where both deltaX and deltaY can be set).
1879 FloatSize delta; 1827 FloatSize delta;
1880 1828
1881 if (wheelEvent->getRailsMode() != Event::RailsModeVertical) 1829 if (wheelEvent->getRailsMode() != Event::RailsModeVertical)
1882 delta.setWidth(wheelEvent->deltaX()); 1830 delta.setWidth(wheelEvent->deltaX());
1883 1831
1884 if (wheelEvent->getRailsMode() != Event::RailsModeHorizontal) 1832 if (wheelEvent->getRailsMode() != Event::RailsModeHorizontal)
1885 delta.setHeight(wheelEvent->deltaY()); 1833 delta.setHeight(wheelEvent->deltaY());
1886 1834
1887 // FIXME: enable scroll customization in this case. See crbug.com/410974. 1835 // FIXME: enable scroll customization in this case. See crbug.com/410974.
1888 ScrollResult result = physicalScroll(granularity, delta, startNode, &node); 1836 bool consumed = false;
1837 ScrollResult result = physicalScroll(granularity, delta, startNode, &node, c onsumed);
1889 1838
1890 if (result.didScroll()) 1839 if (consumed)
1891 wheelEvent->setDefaultHandled(); 1840 wheelEvent->setDefaultHandled();
1841
1842 if (m_frame->isMainFrame() && m_frame->settings() && m_frame->settings()->re portWheelOverscroll())
1843 handleOverscroll(result);
1892 } 1844 }
1893 1845
1894 WebInputEventResult EventHandler::handleGestureShowPress() 1846 WebInputEventResult EventHandler::handleGestureShowPress()
1895 { 1847 {
1896 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); 1848 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime();
1897 1849
1898 FrameView* view = m_frame->view(); 1850 FrameView* view = m_frame->view();
1899 if (!view) 1851 if (!view)
1900 return WebInputEventResult::NotHandled; 1852 return WebInputEventResult::NotHandled;
1901 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) 1853 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator())
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 // This is an optimization which doesn't apply with 2361 // This is an optimization which doesn't apply with
2410 // scroll customization enabled. 2362 // scroll customization enabled.
2411 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; 2363 m_previousGestureScrolledNode = m_scrollGestureHandlingNode;
2412 } 2364 }
2413 // FIXME: we should allow simultaneous scrolling of nested 2365 // FIXME: we should allow simultaneous scrolling of nested
2414 // iframes along perpendicular axes. See crbug.com/466991. 2366 // iframes along perpendicular axes. See crbug.com/466991.
2415 m_deltaConsumedForScrollSequence = true; 2367 m_deltaConsumedForScrollSequence = true;
2416 return result; 2368 return result;
2417 } 2369 }
2418 2370
2419 bool scrolled = false;
2420 if (handleScrollCustomization) { 2371 if (handleScrollCustomization) {
2421 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta()); 2372 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta());
2422 scrollStateData->delta_x = delta.width(); 2373 scrollStateData->delta_x = delta.width();
2423 scrollStateData->delta_y = delta.height(); 2374 scrollStateData->delta_y = delta.height();
2424 scrollStateData->velocity_x = velocity.width(); 2375 scrollStateData->velocity_x = velocity.width();
2425 scrollStateData->velocity_y = velocity.height(); 2376 scrollStateData->velocity_y = velocity.height();
2426 scrollStateData->should_propagate = !gestureEvent.preventPropagation (); 2377 scrollStateData->should_propagate = !gestureEvent.preventPropagation ();
2427 scrollStateData->is_in_inertial_phase = gestureEvent.inertial(); 2378 scrollStateData->is_in_inertial_phase = gestureEvent.inertial();
2428 scrollStateData->from_user_input = true; 2379 scrollStateData->from_user_input = true;
2429 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence; 2380 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence;
2430 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc rollStateData.release()); 2381 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc rollStateData.release());
2431 if (m_previousGestureScrolledNode) { 2382 if (m_previousGestureScrolledNode) {
2432 // The ScrollState needs to know what the current 2383 // The ScrollState needs to know what the current
2433 // native scrolling element is, so that for an 2384 // native scrolling element is, so that for an
2434 // inertial scroll that shouldn't propagate, only the 2385 // inertial scroll that shouldn't propagate, only the
2435 // currently scrolling element responds. 2386 // currently scrolling element responds.
2436 ASSERT(m_previousGestureScrolledNode->isElementNode()); 2387 ASSERT(m_previousGestureScrolledNode->isElementNode());
2437 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get())); 2388 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get()));
2438 } 2389 }
2439 customizedScroll(*node, *scrollState); 2390 customizedScroll(*node, *scrollState);
2440 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); 2391 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement();
2441 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); 2392 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence();
2442 scrolled = scrollState->deltaX() != delta.width() 2393 if (scrollState->deltaX() != delta.width()
2443 || scrollState->deltaY() != delta.height(); 2394 || scrollState->deltaY() != delta.width()) {
2395 setFrameWasScrolledByUser();
2396 return WebInputEventResult::HandledSystem;
2397 }
2444 } else { 2398 } else {
2445 Node* stopNode = nullptr; 2399 Node* stopNode = nullptr;
2446 if (gestureEvent.preventPropagation()) 2400 if (gestureEvent.preventPropagation())
2447 stopNode = m_previousGestureScrolledNode.get(); 2401 stopNode = m_previousGestureScrolledNode.get();
2448 2402
2449 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node); 2403 bool consumed = false;
2450 2404 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node, consumed);
2451 scrolled = result.didScroll();
2452 2405
2453 if (gestureEvent.preventPropagation()) 2406 if (gestureEvent.preventPropagation())
2454 m_previousGestureScrolledNode = stopNode; 2407 m_previousGestureScrolledNode = stopNode;
2455 2408
2456 resetOverscroll(result.didScrollX, result.didScrollY); 2409 if (m_frame->isMainFrame() && (!stopNode || stopNode->layoutObject() == m_frame->view()->layoutView())) {
2457 } 2410 FloatPoint position = FloatPoint(gestureEvent.position().x(), ge stureEvent.position().y());
2458 if (scrolled) { 2411 handleOverscroll(result, position, velocity);
2459 setFrameWasScrolledByUser(); 2412 } else {
2460 return WebInputEventResult::HandledSystem; 2413 resetOverscroll(result.didScrollX, result.didScrollY);
2414 }
2415
2416 if (consumed)
2417 return WebInputEventResult::HandledSystem;
2461 } 2418 }
2462 } 2419 }
2463 2420
2464 if (handleScrollCustomization)
2465 return WebInputEventResult::NotHandled;
2466
2467 // Try to scroll the frame view.
2468 ScrollResult scrollResult = m_frame->applyScrollDelta(granularity, delta, fa lse);
2469 if (m_frame->isMainFrame()) {
2470 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEve nt.position().y());
2471 handleOverscroll(scrollResult, position, velocity);
2472 }
2473 if (scrollResult.didScroll()) {
2474 setFrameWasScrolledByUser();
2475 return WebInputEventResult::HandledSystem;
2476 }
2477
2478 return WebInputEventResult::NotHandled; 2421 return WebInputEventResult::NotHandled;
2479 } 2422 }
2480 2423
2481 void EventHandler::clearGestureScrollState() 2424 void EventHandler::clearGestureScrollState()
2482 { 2425 {
2483 m_scrollGestureHandlingNode = nullptr; 2426 m_scrollGestureHandlingNode = nullptr;
2484 m_previousGestureScrolledNode = nullptr; 2427 m_previousGestureScrolledNode = nullptr;
2485 m_deltaConsumedForScrollSequence = false; 2428 m_deltaConsumedForScrollSequence = false;
2486 m_currentScrollChain.clear(); 2429 m_currentScrollChain.clear();
2487 m_accumulatedRootOverscroll = FloatSize(); 2430 m_accumulatedRootOverscroll = FloatSize();
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
3427 if (event->ctrlKey() || event->metaKey() || event->altKey()) 3370 if (event->ctrlKey() || event->metaKey() || event->altKey())
3428 return; 3371 return;
3429 3372
3430 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; 3373 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward;
3431 3374
3432 // FIXME: enable scroll customization in this case. See crbug.com/410974. 3375 // FIXME: enable scroll customization in this case. See crbug.com/410974.
3433 if (logicalScroll(direction, ScrollByPage)) { 3376 if (logicalScroll(direction, ScrollByPage)) {
3434 event->setDefaultHandled(); 3377 event->setDefaultHandled();
3435 return; 3378 return;
3436 } 3379 }
3437
3438 FrameView* view = m_frame->view();
3439 if (!view)
3440 return;
3441
3442 ScrollDirectionPhysical physicalDirection =
3443 toPhysicalDirection(direction, view->isVerticalDocument(), view->isFlipp edDocument());
3444
3445 if (view->scrollableArea()->userScroll(ScrollByPage, toScrollDelta(physicalD irection, 1)).didScroll())
3446 event->setDefaultHandled();
3447 } 3380 }
3448 3381
3449 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) 3382 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event)
3450 { 3383 {
3451 ASSERT(event->type() == EventTypeNames::keydown); 3384 ASSERT(event->type() == EventTypeNames::keydown);
3452 3385
3453 if (event->ctrlKey() || event->metaKey() || event->altKey()) 3386 if (event->ctrlKey() || event->metaKey() || event->altKey())
3454 return; 3387 return;
3455 3388
3456 if (!m_frame->editor().behavior().shouldNavigateBackOnBackspace()) 3389 if (!m_frame->editor().behavior().shouldNavigateBackOnBackspace())
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
3994 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 3927 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
3995 { 3928 {
3996 #if OS(MACOSX) 3929 #if OS(MACOSX)
3997 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 3930 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
3998 #else 3931 #else
3999 return PlatformEvent::AltKey; 3932 return PlatformEvent::AltKey;
4000 #endif 3933 #endif
4001 } 3934 }
4002 3935
4003 } // namespace blink 3936 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698