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

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: Fixes for layout tests breaks 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)
604 { 604 {
605 if (consumed)
606 *consumed = false;
605 if (delta.isZero()) 607 if (delta.isZero())
606 return ScrollResult(); 608 return ScrollResult();
607 609
608 Node* node = startNode; 610 Node* node = startNode;
609 ASSERT(node && node->layoutObject()); 611 ASSERT(node && node->layoutObject());
610 612
611 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 613 m_frame->document()->updateLayoutIgnorePendingStylesheets();
612 614
613 ScrollResult result; 615 ScrollResult result;
614 616
615 LayoutBox* curBox = node->layoutObject()->enclosingBox(); 617 LayoutBox* curBox = node->layoutObject()->enclosingBox();
616 while (curBox && !curBox->isLayoutView()) { 618 while (curBox) {
617 // If we're at the stopNode, we should try to scroll it but we shouldn't 619 // If we're at the stopNode, we should try to scroll it but we shouldn't
618 // chain past it. 620 // chain past it.
619 bool shouldStopChaining = 621 bool shouldStopChaining =
620 stopNode && *stopNode && curBox->node() == *stopNode; 622 stopNode && *stopNode && curBox->node() == *stopNode;
621 result = curBox->scroll(granularity, delta); 623 result = curBox->scroll(granularity, delta);
622 624
623 if (result.didScroll() && stopNode) 625 if (result.didScroll() && stopNode)
624 *stopNode = curBox->node(); 626 *stopNode = curBox->node();
625 627
626 if (result.didScroll() || shouldStopChaining) { 628 if (result.didScroll() || shouldStopChaining) {
627 setFrameWasScrolledByUser(); 629 setFrameWasScrolledByUser();
628 if (!result.didScroll()) { 630 if (consumed)
629 // TODO(bokan): We should probably add a "shouldPropagate" bit 631 *consumed = true;
630 // on the result rather than lying to the caller.
631 result.didScrollX = true;
632 result.didScrollY = true;
633 }
634 return result; 632 return result;
635 } 633 }
636 634
637 curBox = curBox->containingBlock(); 635 curBox = curBox->containingBlock();
638 } 636 }
639 637
640 return result; 638 return result;
641 } 639 }
642 640
643 bool EventHandler::logicalScroll(ScrollDirection direction, ScrollGranularity gr anularity, Node* startNode) 641 bool EventHandler::logicalScroll(ScrollDirection direction, ScrollGranularity gr anularity, Node* startNode)
644 { 642 {
645 Node* node = startNode; 643 Node* node = startNode;
646 644
647 if (!node) 645 if (!node)
648 node = m_frame->document()->focusedElement(); 646 node = m_frame->document()->focusedElement();
649 647
650 if (!node) 648 if (!node)
651 node = m_mousePressNode.get(); 649 node = m_mousePressNode.get();
652 650
653 if (!node || !node->layoutObject()) 651 if (!node || !node->layoutObject())
654 return false; 652 node = m_frame->view()->layoutView()->node();
655 653
656 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 654 m_frame->document()->updateLayoutIgnorePendingStylesheets();
657 655
658 LayoutBox* curBox = node->layoutObject()->enclosingBox(); 656 LayoutBox* curBox = node->layoutObject()->enclosingBox();
659 while (curBox && !curBox->isLayoutView()) { 657 while (curBox) {
660 ScrollDirectionPhysical physicalDirection = toPhysicalDirection( 658 ScrollDirectionPhysical physicalDirection = toPhysicalDirection(
661 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode()); 659 direction, curBox->isHorizontalWritingMode(), curBox->style()->isFli ppedBlocksWritingMode());
662 660
663 ScrollResult result = curBox->scroll(granularity, toScrollDelta(physical Direction, 1)); 661 ScrollResult result = curBox->scroll(granularity, toScrollDelta(physical Direction, 1));
664 662
665 if (result.didScroll()) { 663 if (result.didScroll()) {
666 setFrameWasScrolledByUser(); 664 setFrameWasScrolledByUser();
667 return true; 665 return true;
668 } 666 }
669 667
(...skipping 21 matching lines...) Expand all
691 // TODO(bokan): This should be merged with logicalScroll assuming 689 // TODO(bokan): This should be merged with logicalScroll assuming
692 // defaultSpaceEventHandler's chaining scroll can be done crossing frames. 690 // defaultSpaceEventHandler's chaining scroll can be done crossing frames.
693 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode) 691 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g ranularity, Node* startingNode)
694 { 692 {
695 // The layout needs to be up to date to determine if we can scroll. We may b e 693 // 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. 694 // here because of an onLoad event, in which case the final layout hasn't be en performed yet.
697 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 695 m_frame->document()->updateLayoutIgnorePendingStylesheets();
698 // FIXME: enable scroll customization in this case. See crbug.com/410974. 696 // FIXME: enable scroll customization in this case. See crbug.com/410974.
699 if (logicalScroll(direction, granularity, startingNode)) 697 if (logicalScroll(direction, granularity, startingNode))
700 return true; 698 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 699
712 Frame* parentFrame = frame->tree().parent(); 700 Frame* parentFrame = m_frame->tree().parent();
713 if (!parentFrame || !parentFrame->isLocalFrame()) 701 if (!parentFrame || !parentFrame->isLocalFrame())
714 return false; 702 return false;
715 // FIXME: Broken for OOPI. 703 // FIXME: Broken for OOPI.
716 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner()); 704 return toLocalFrame(parentFrame)->eventHandler().bubblingScroll(direction, g ranularity, m_frame->deprecatedLocalOwner());
717 } 705 }
718 706
719 IntPoint EventHandler::lastKnownMousePosition() const 707 IntPoint EventHandler::lastKnownMousePosition() const
720 { 708 {
721 return m_lastKnownMousePosition; 709 return m_lastKnownMousePosition;
722 } 710 }
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 Element* found = page->focusController().findFocusableElementInShadowHos t(element); 1765 Element* found = page->focusController().findFocusableElementInShadowHos t(element);
1778 if (found && element.containsIncludingShadowDOM(found)) { 1766 if (found && element.containsIncludingShadowDOM(found)) {
1779 // Use WebFocusTypeForward instead of WebFocusTypeMouse here to mean the focus has slided. 1767 // Use WebFocusTypeForward instead of WebFocusTypeMouse here to mean the focus has slided.
1780 found->focus(FocusParams(SelectionBehaviorOnFocus::Reset, WebFocusTy peForward, nullptr)); 1768 found->focus(FocusParams(SelectionBehaviorOnFocus::Reset, WebFocusTy peForward, nullptr));
1781 return true; 1769 return true;
1782 } 1770 }
1783 } 1771 }
1784 return false; 1772 return false;
1785 } 1773 }
1786 1774
1787 namespace {
1788
1789 ScrollResult scrollAreaWithWheelEvent(const PlatformWheelEvent& event, Scrollabl eArea& scrollableArea)
1790 {
1791 float deltaX = event.getRailsMode() != PlatformEvent::RailsModeVertical ? ev ent.deltaX() : 0;
1792 float deltaY = event.getRailsMode() != PlatformEvent::RailsModeHorizontal ? event.deltaY() : 0;
1793
1794 ScrollGranularity granularity =
1795 event.granularity() == ScrollByPixelWheelEvent ? ScrollByPixel : ScrollB yPage;
1796
1797 if (event.hasPreciseScrollingDeltas() && granularity == ScrollByPixel)
1798 granularity = ScrollByPrecisePixel;
1799
1800 // If the event is a "PageWheelEvent" we should disregard the delta and
1801 // scroll by *one* page length per event.
1802 if (event.granularity() == ScrollByPageWheelEvent) {
1803 if (deltaX)
1804 deltaX = deltaX > 0 ? 1 : -1;
1805 if (deltaY)
1806 deltaY = deltaY > 0 ? 1 : -1;
1807 }
1808
1809 // On a wheel event, positive delta is meant to scroll up and left, which
1810 // is the opposite of deltas in the scrolling system.
1811 return scrollableArea.userScroll(granularity, FloatSize(-deltaX, -deltaY));
1812 }
1813
1814 } // namespace
1815
1816 WebInputEventResult EventHandler::handleWheelEvent(const PlatformWheelEvent& eve nt) 1775 WebInputEventResult EventHandler::handleWheelEvent(const PlatformWheelEvent& eve nt)
1817 { 1776 {
1818 Document* doc = m_frame->document(); 1777 Document* doc = m_frame->document();
1819 1778
1820 if (!doc->layoutView()) 1779 if (!doc->layoutView())
1821 return WebInputEventResult::NotHandled; 1780 return WebInputEventResult::NotHandled;
1822 1781
1823 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); 1782 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view());
1824 1783
1825 FrameView* view = m_frame->view(); 1784 FrameView* view = m_frame->view();
(...skipping 20 matching lines...) Expand all
1846 return result; 1805 return result;
1847 } 1806 }
1848 // TODO(dtapuska): Remove this once wheel gesture scroll has 1807 // TODO(dtapuska): Remove this once wheel gesture scroll has
1849 // been enabled everywhere; as we can just return early. 1808 // been enabled everywhere; as we can just return early.
1850 // http://crbug.com/568183 1809 // http://crbug.com/568183
1851 // Don't propagate the DOM event into the parent iframe 1810 // Don't propagate the DOM event into the parent iframe
1852 // but do dispatch the scroll event. 1811 // but do dispatch the scroll event.
1853 sendDOMEvent = false; 1812 sendDOMEvent = false;
1854 } 1813 }
1855 1814
1856 if (node && sendDOMEvent) { 1815 if (node) {
1857 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc ument().domWindow()); 1816 RefPtrWillBeRawPtr<WheelEvent> domEvent = WheelEvent::create(event, node ->document().domWindow());
1858 DispatchEventResult domEventResult = node->dispatchEvent(domEvent); 1817 if (sendDOMEvent) {
1859 if (domEventResult != DispatchEventResult::NotCanceled) { 1818 DispatchEventResult domEventResult = node->dispatchEvent(domEvent);
1860 setFrameWasScrolledByUser(); 1819 if (domEventResult != DispatchEventResult::NotCanceled)
1861 return toWebInputEventResult(domEventResult); 1820 return toWebInputEventResult(domEventResult);
1821 } else {
1822 defaultWheelEventHandler(node, domEvent.get());
1823 if (domEvent->defaultHandled())
1824 return WebInputEventResult::HandledSystem;
1862 } 1825 }
1863 } 1826 }
1864 1827
1865 // We do another check on the frame view because the event handler can run
1866 // JS which results in the frame getting destroyed.
1867 view = m_frame->view();
1868 if (!view)
1869 return WebInputEventResult::NotHandled;
1870
1871 // Wheel events which do not scroll are used to trigger zooming.
1872 if (!event.canScroll())
1873 return WebInputEventResult::NotHandled;
1874
1875 ScrollResult scrollResult = scrollAreaWithWheelEvent(event, *view->scrollabl eArea());
1876 if (m_frame->isMainFrame() && m_frame->settings() && m_frame->settings()->re portWheelOverscroll())
1877 handleOverscroll(scrollResult);
1878 if (scrollResult.didScroll()) {
1879 setFrameWasScrolledByUser();
1880 return WebInputEventResult::HandledSystem;
1881 }
1882
1883 return WebInputEventResult::NotHandled; 1828 return WebInputEventResult::NotHandled;
1884 } 1829 }
1885 1830
1886 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) 1831 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent)
1887 { 1832 {
1888 if (!startNode || !wheelEvent) 1833 if (!startNode || !wheelEvent)
1889 return; 1834 return;
1890 1835
1891 // When the wheelEvent do not scroll, we trigger zoom in/out instead. 1836 // When the wheelEvent do not scroll, we trigger zoom in/out instead.
1892 if (!wheelEvent->canScroll()) 1837 if (!wheelEvent->canScroll())
1893 return; 1838 return;
1894 1839
1895 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt); 1840 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve nt);
1896 Node* node = nullptr; 1841 Node* node = nullptr;
1897 1842
1898 // Diagonal movement on a MacBook pro is an example of a 2-dimensional 1843 // Diagonal movement on a MacBook pro is an example of a 2-dimensional
1899 // mouse wheel event (where both deltaX and deltaY can be set). 1844 // mouse wheel event (where both deltaX and deltaY can be set).
1900 FloatSize delta; 1845 FloatSize delta;
1901 1846
1902 if (wheelEvent->getRailsMode() != Event::RailsModeVertical) 1847 if (wheelEvent->getRailsMode() != Event::RailsModeVertical)
1903 delta.setWidth(wheelEvent->deltaX()); 1848 delta.setWidth(wheelEvent->deltaX());
1904 1849
1905 if (wheelEvent->getRailsMode() != Event::RailsModeHorizontal) 1850 if (wheelEvent->getRailsMode() != Event::RailsModeHorizontal)
1906 delta.setHeight(wheelEvent->deltaY()); 1851 delta.setHeight(wheelEvent->deltaY());
1907 1852
1853 // We can get page wheel events with non-[0|1] deltas in the case where the
1854 // events are coalesced but we still want to scroll by just one page length.
1855 // TODO(bokan): This seems like it belongs in the coalescing logic.
1856 if (granularity == ScrollByPage) {
1857 if (delta.width())
1858 delta.setWidth(delta.width() > 0 ? 1 : -1);
1859 if (delta.height())
1860 delta.setHeight(delta.height() > 0 ? 1 : -1);
1861 }
1862
1908 // FIXME: enable scroll customization in this case. See crbug.com/410974. 1863 // FIXME: enable scroll customization in this case. See crbug.com/410974.
1909 ScrollResult result = physicalScroll(granularity, delta, startNode, &node); 1864 bool consumed = false;
1865 ScrollResult result = physicalScroll(granularity, delta, startNode, &node, & consumed);
1910 1866
1911 if (result.didScroll()) 1867 if (consumed)
1912 wheelEvent->setDefaultHandled(); 1868 wheelEvent->setDefaultHandled();
1869
1870 if (m_frame->isMainFrame() && m_frame->settings() && m_frame->settings()->re portWheelOverscroll())
1871 handleOverscroll(result);
1913 } 1872 }
1914 1873
1915 WebInputEventResult EventHandler::handleGestureShowPress() 1874 WebInputEventResult EventHandler::handleGestureShowPress()
1916 { 1875 {
1917 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); 1876 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime();
1918 1877
1919 FrameView* view = m_frame->view(); 1878 FrameView* view = m_frame->view();
1920 if (!view) 1879 if (!view)
1921 return WebInputEventResult::NotHandled; 1880 return WebInputEventResult::NotHandled;
1922 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) 1881 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator())
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 // This is an optimization which doesn't apply with 2389 // This is an optimization which doesn't apply with
2431 // scroll customization enabled. 2390 // scroll customization enabled.
2432 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; 2391 m_previousGestureScrolledNode = m_scrollGestureHandlingNode;
2433 } 2392 }
2434 // FIXME: we should allow simultaneous scrolling of nested 2393 // FIXME: we should allow simultaneous scrolling of nested
2435 // iframes along perpendicular axes. See crbug.com/466991. 2394 // iframes along perpendicular axes. See crbug.com/466991.
2436 m_deltaConsumedForScrollSequence = true; 2395 m_deltaConsumedForScrollSequence = true;
2437 return result; 2396 return result;
2438 } 2397 }
2439 2398
2440 bool scrolled = false;
2441 if (handleScrollCustomization) { 2399 if (handleScrollCustomization) {
2442 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta()); 2400 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa ta());
2443 scrollStateData->delta_x = delta.width(); 2401 scrollStateData->delta_x = delta.width();
2444 scrollStateData->delta_y = delta.height(); 2402 scrollStateData->delta_y = delta.height();
2445 scrollStateData->velocity_x = velocity.width(); 2403 scrollStateData->velocity_x = velocity.width();
2446 scrollStateData->velocity_y = velocity.height(); 2404 scrollStateData->velocity_y = velocity.height();
2447 scrollStateData->should_propagate = !gestureEvent.preventPropagation (); 2405 scrollStateData->should_propagate = !gestureEvent.preventPropagation ();
2448 scrollStateData->is_in_inertial_phase = gestureEvent.inertial(); 2406 scrollStateData->is_in_inertial_phase = gestureEvent.inertial();
2449 scrollStateData->from_user_input = true; 2407 scrollStateData->from_user_input = true;
2450 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence; 2408 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume dForScrollSequence;
2451 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc rollStateData.release()); 2409 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc rollStateData.release());
2452 if (m_previousGestureScrolledNode) { 2410 if (m_previousGestureScrolledNode) {
2453 // The ScrollState needs to know what the current 2411 // The ScrollState needs to know what the current
2454 // native scrolling element is, so that for an 2412 // native scrolling element is, so that for an
2455 // inertial scroll that shouldn't propagate, only the 2413 // inertial scroll that shouldn't propagate, only the
2456 // currently scrolling element responds. 2414 // currently scrolling element responds.
2457 ASSERT(m_previousGestureScrolledNode->isElementNode()); 2415 ASSERT(m_previousGestureScrolledNode->isElementNode());
2458 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get())); 2416 scrollState->setCurrentNativeScrollingElement(toElement(m_previo usGestureScrolledNode.get()));
2459 } 2417 }
2460 customizedScroll(*node, *scrollState); 2418 customizedScroll(*node, *scrollState);
2461 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement(); 2419 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE lement();
2462 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence(); 2420 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro llSequence();
2463 scrolled = scrollState->deltaX() != delta.width() 2421 if (scrollState->deltaX() != delta.width()
2464 || scrollState->deltaY() != delta.height(); 2422 || scrollState->deltaY() != delta.height()) {
2423 setFrameWasScrolledByUser();
2424 return WebInputEventResult::HandledSystem;
2425 }
2465 } else { 2426 } else {
2466 Node* stopNode = nullptr; 2427 Node* stopNode = nullptr;
2467 if (gestureEvent.preventPropagation()) 2428 if (gestureEvent.preventPropagation())
2468 stopNode = m_previousGestureScrolledNode.get(); 2429 stopNode = m_previousGestureScrolledNode.get();
2469 2430
2470 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node); 2431 bool consumed = false;
2471 2432 ScrollResult result = physicalScroll(granularity, delta, node, &stop Node, &consumed);
2472 scrolled = result.didScroll();
2473 2433
2474 if (gestureEvent.preventPropagation()) 2434 if (gestureEvent.preventPropagation())
2475 m_previousGestureScrolledNode = stopNode; 2435 m_previousGestureScrolledNode = stopNode;
2476 2436
2477 resetOverscroll(result.didScrollX, result.didScrollY); 2437 if (m_frame->isMainFrame() && (!stopNode || stopNode->layoutObject() == m_frame->view()->layoutView())) {
2478 } 2438 FloatPoint position = FloatPoint(gestureEvent.position().x(), ge stureEvent.position().y());
2479 if (scrolled) { 2439 handleOverscroll(result, position, velocity);
2480 setFrameWasScrolledByUser(); 2440 } else {
2481 return WebInputEventResult::HandledSystem; 2441 resetOverscroll(result.didScrollX, result.didScrollY);
2442 }
2443
2444 if (consumed)
2445 return WebInputEventResult::HandledSystem;
2482 } 2446 }
2483 } 2447 }
2484 2448
2485 if (handleScrollCustomization)
2486 return WebInputEventResult::NotHandled;
2487
2488 // Try to scroll the frame view.
2489 ScrollResult scrollResult = m_frame->applyScrollDelta(granularity, delta, fa lse);
2490 if (m_frame->isMainFrame()) {
2491 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEve nt.position().y());
2492 handleOverscroll(scrollResult, position, velocity);
2493 }
2494 if (scrollResult.didScroll()) {
2495 setFrameWasScrolledByUser();
2496 return WebInputEventResult::HandledSystem;
2497 }
2498
2499 return WebInputEventResult::NotHandled; 2449 return WebInputEventResult::NotHandled;
2500 } 2450 }
2501 2451
2502 void EventHandler::clearGestureScrollState() 2452 void EventHandler::clearGestureScrollState()
2503 { 2453 {
2504 m_scrollGestureHandlingNode = nullptr; 2454 m_scrollGestureHandlingNode = nullptr;
2505 m_previousGestureScrolledNode = nullptr; 2455 m_previousGestureScrolledNode = nullptr;
2506 m_deltaConsumedForScrollSequence = false; 2456 m_deltaConsumedForScrollSequence = false;
2507 m_currentScrollChain.clear(); 2457 m_currentScrollChain.clear();
2508 m_accumulatedRootOverscroll = FloatSize(); 2458 m_accumulatedRootOverscroll = FloatSize();
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 if (event->ctrlKey() || event->metaKey() || event->altKey()) 3398 if (event->ctrlKey() || event->metaKey() || event->altKey())
3449 return; 3399 return;
3450 3400
3451 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward; 3401 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward : ScrollBlockDirectionForward;
3452 3402
3453 // FIXME: enable scroll customization in this case. See crbug.com/410974. 3403 // FIXME: enable scroll customization in this case. See crbug.com/410974.
3454 if (logicalScroll(direction, ScrollByPage)) { 3404 if (logicalScroll(direction, ScrollByPage)) {
3455 event->setDefaultHandled(); 3405 event->setDefaultHandled();
3456 return; 3406 return;
3457 } 3407 }
3458
3459 FrameView* view = m_frame->view();
3460 if (!view)
3461 return;
3462
3463 ScrollDirectionPhysical physicalDirection =
3464 toPhysicalDirection(direction, view->isVerticalDocument(), view->isFlipp edDocument());
3465
3466 if (view->scrollableArea()->userScroll(ScrollByPage, toScrollDelta(physicalD irection, 1)).didScroll())
3467 event->setDefaultHandled();
3468 } 3408 }
3469 3409
3470 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) 3410 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event)
3471 { 3411 {
3472 ASSERT(event->type() == EventTypeNames::keydown); 3412 ASSERT(event->type() == EventTypeNames::keydown);
3473 3413
3474 if (event->ctrlKey() || event->metaKey() || event->altKey()) 3414 if (event->ctrlKey() || event->metaKey() || event->altKey())
3475 return; 3415 return;
3476 3416
3477 if (!m_frame->editor().behavior().shouldNavigateBackOnBackspace()) 3417 if (!m_frame->editor().behavior().shouldNavigateBackOnBackspace())
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
4015 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 3955 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4016 { 3956 {
4017 #if OS(MACOSX) 3957 #if OS(MACOSX)
4018 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 3958 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4019 #else 3959 #else
4020 return PlatformEvent::AltKey; 3960 return PlatformEvent::AltKey;
4021 #endif 3961 #endif
4022 } 3962 }
4023 3963
4024 } // namespace blink 3964 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698