| OLD | NEW |
| 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 Loading... |
| 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 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->containingBlock(); |
| 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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 Loading... |
| 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; | |
| 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 20 matching lines...) Expand all Loading... |
| 1825 return result; | 1782 return result; |
| 1826 } | 1783 } |
| 1827 // TODO(dtapuska): Remove this once wheel gesture scroll has | 1784 // TODO(dtapuska): Remove this once wheel gesture scroll has |
| 1828 // been enabled everywhere; as we can just return early. | 1785 // been enabled everywhere; as we can just return early. |
| 1829 // http://crbug.com/568183 | 1786 // http://crbug.com/568183 |
| 1830 // Don't propagate the DOM event into the parent iframe | 1787 // Don't propagate the DOM event into the parent iframe |
| 1831 // but do dispatch the scroll event. | 1788 // but do dispatch the scroll event. |
| 1832 sendDOMEvent = false; | 1789 sendDOMEvent = false; |
| 1833 } | 1790 } |
| 1834 | 1791 |
| 1835 if (node && sendDOMEvent) { | 1792 if (node) { |
| 1836 RefPtrWillBeRawPtr<Event> domEvent = WheelEvent::create(event, node->doc
ument().domWindow()); | 1793 RefPtrWillBeRawPtr<WheelEvent> domEvent = WheelEvent::create(event, node
->document().domWindow()); |
| 1837 DispatchEventResult domEventResult = node->dispatchEvent(domEvent); | 1794 if (sendDOMEvent) { |
| 1838 if (domEventResult != DispatchEventResult::NotCanceled) { | 1795 DispatchEventResult domEventResult = node->dispatchEvent(domEvent); |
| 1839 setFrameWasScrolledByUser(); | 1796 if (domEventResult != DispatchEventResult::NotCanceled) |
| 1840 return toWebInputEventResult(domEventResult); | 1797 return toWebInputEventResult(domEventResult); |
| 1798 } else { |
| 1799 defaultWheelEventHandler(node, domEvent.get()); |
| 1800 if (domEvent->defaultHandled()) |
| 1801 return WebInputEventResult::HandledSystem; |
| 1841 } | 1802 } |
| 1842 } | 1803 } |
| 1843 | 1804 |
| 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; | 1805 return WebInputEventResult::NotHandled; |
| 1863 } | 1806 } |
| 1864 | 1807 |
| 1865 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv
ent) | 1808 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv
ent) |
| 1866 { | 1809 { |
| 1867 if (!startNode || !wheelEvent) | 1810 if (!startNode || !wheelEvent) |
| 1868 return; | 1811 return; |
| 1869 | 1812 |
| 1870 // When the wheelEvent do not scroll, we trigger zoom in/out instead. | 1813 // When the wheelEvent do not scroll, we trigger zoom in/out instead. |
| 1871 if (!wheelEvent->canScroll()) | 1814 if (!wheelEvent->canScroll()) |
| 1872 return; | 1815 return; |
| 1873 | 1816 |
| 1874 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve
nt); | 1817 ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEve
nt); |
| 1875 Node* node = nullptr; | 1818 Node* node = nullptr; |
| 1876 | 1819 |
| 1877 // Diagonal movement on a MacBook pro is an example of a 2-dimensional | 1820 // 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). | 1821 // mouse wheel event (where both deltaX and deltaY can be set). |
| 1879 FloatSize delta; | 1822 FloatSize delta; |
| 1880 | 1823 |
| 1881 if (wheelEvent->getRailsMode() != Event::RailsModeVertical) | 1824 if (wheelEvent->getRailsMode() != Event::RailsModeVertical) |
| 1882 delta.setWidth(wheelEvent->deltaX()); | 1825 delta.setWidth(wheelEvent->deltaX()); |
| 1883 | 1826 |
| 1884 if (wheelEvent->getRailsMode() != Event::RailsModeHorizontal) | 1827 if (wheelEvent->getRailsMode() != Event::RailsModeHorizontal) |
| 1885 delta.setHeight(wheelEvent->deltaY()); | 1828 delta.setHeight(wheelEvent->deltaY()); |
| 1886 | 1829 |
| 1830 // We can get page wheel events with non-[0|1] deltas in the case where the |
| 1831 // events are coalesced but we still want to scroll by just one page length. |
| 1832 // TODO(bokan): This seems like it belongs in the coalescing logic. |
| 1833 if (granularity == ScrollByPage) { |
| 1834 if (delta.width()) |
| 1835 delta.setWidth(delta.width() > 0 ? 1 : -1); |
| 1836 if (delta.height()) |
| 1837 delta.setHeight(delta.height() > 0 ? 1 : -1); |
| 1838 } |
| 1839 |
| 1887 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 1840 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 1888 ScrollResult result = physicalScroll(granularity, delta, startNode, &node); | 1841 bool consumed = false; |
| 1842 ScrollResult result = physicalScroll(granularity, delta, startNode, &node, c
onsumed); |
| 1889 | 1843 |
| 1890 if (result.didScroll()) | 1844 if (consumed) |
| 1891 wheelEvent->setDefaultHandled(); | 1845 wheelEvent->setDefaultHandled(); |
| 1846 |
| 1847 if (m_frame->isMainFrame() && m_frame->settings() && m_frame->settings()->re
portWheelOverscroll()) |
| 1848 handleOverscroll(result); |
| 1892 } | 1849 } |
| 1893 | 1850 |
| 1894 WebInputEventResult EventHandler::handleGestureShowPress() | 1851 WebInputEventResult EventHandler::handleGestureShowPress() |
| 1895 { | 1852 { |
| 1896 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); | 1853 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); |
| 1897 | 1854 |
| 1898 FrameView* view = m_frame->view(); | 1855 FrameView* view = m_frame->view(); |
| 1899 if (!view) | 1856 if (!view) |
| 1900 return WebInputEventResult::NotHandled; | 1857 return WebInputEventResult::NotHandled; |
| 1901 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) | 1858 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2409 // This is an optimization which doesn't apply with | 2366 // This is an optimization which doesn't apply with |
| 2410 // scroll customization enabled. | 2367 // scroll customization enabled. |
| 2411 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; | 2368 m_previousGestureScrolledNode = m_scrollGestureHandlingNode; |
| 2412 } | 2369 } |
| 2413 // FIXME: we should allow simultaneous scrolling of nested | 2370 // FIXME: we should allow simultaneous scrolling of nested |
| 2414 // iframes along perpendicular axes. See crbug.com/466991. | 2371 // iframes along perpendicular axes. See crbug.com/466991. |
| 2415 m_deltaConsumedForScrollSequence = true; | 2372 m_deltaConsumedForScrollSequence = true; |
| 2416 return result; | 2373 return result; |
| 2417 } | 2374 } |
| 2418 | 2375 |
| 2419 bool scrolled = false; | |
| 2420 if (handleScrollCustomization) { | 2376 if (handleScrollCustomization) { |
| 2421 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa
ta()); | 2377 OwnPtr<ScrollStateData> scrollStateData = adoptPtr(new ScrollStateDa
ta()); |
| 2422 scrollStateData->delta_x = delta.width(); | 2378 scrollStateData->delta_x = delta.width(); |
| 2423 scrollStateData->delta_y = delta.height(); | 2379 scrollStateData->delta_y = delta.height(); |
| 2424 scrollStateData->velocity_x = velocity.width(); | 2380 scrollStateData->velocity_x = velocity.width(); |
| 2425 scrollStateData->velocity_y = velocity.height(); | 2381 scrollStateData->velocity_y = velocity.height(); |
| 2426 scrollStateData->should_propagate = !gestureEvent.preventPropagation
(); | 2382 scrollStateData->should_propagate = !gestureEvent.preventPropagation
(); |
| 2427 scrollStateData->is_in_inertial_phase = gestureEvent.inertial(); | 2383 scrollStateData->is_in_inertial_phase = gestureEvent.inertial(); |
| 2428 scrollStateData->from_user_input = true; | 2384 scrollStateData->from_user_input = true; |
| 2429 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume
dForScrollSequence; | 2385 scrollStateData->delta_consumed_for_scroll_sequence = m_deltaConsume
dForScrollSequence; |
| 2430 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc
rollStateData.release()); | 2386 RefPtrWillBeRawPtr<ScrollState> scrollState = ScrollState::create(sc
rollStateData.release()); |
| 2431 if (m_previousGestureScrolledNode) { | 2387 if (m_previousGestureScrolledNode) { |
| 2432 // The ScrollState needs to know what the current | 2388 // The ScrollState needs to know what the current |
| 2433 // native scrolling element is, so that for an | 2389 // native scrolling element is, so that for an |
| 2434 // inertial scroll that shouldn't propagate, only the | 2390 // inertial scroll that shouldn't propagate, only the |
| 2435 // currently scrolling element responds. | 2391 // currently scrolling element responds. |
| 2436 ASSERT(m_previousGestureScrolledNode->isElementNode()); | 2392 ASSERT(m_previousGestureScrolledNode->isElementNode()); |
| 2437 scrollState->setCurrentNativeScrollingElement(toElement(m_previo
usGestureScrolledNode.get())); | 2393 scrollState->setCurrentNativeScrollingElement(toElement(m_previo
usGestureScrolledNode.get())); |
| 2438 } | 2394 } |
| 2439 customizedScroll(*node, *scrollState); | 2395 customizedScroll(*node, *scrollState); |
| 2440 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE
lement(); | 2396 m_previousGestureScrolledNode = scrollState->currentNativeScrollingE
lement(); |
| 2441 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro
llSequence(); | 2397 m_deltaConsumedForScrollSequence = scrollState->deltaConsumedForScro
llSequence(); |
| 2442 scrolled = scrollState->deltaX() != delta.width() | 2398 if (scrollState->deltaX() != delta.width() |
| 2443 || scrollState->deltaY() != delta.height(); | 2399 || scrollState->deltaY() != delta.width()) { |
| 2400 setFrameWasScrolledByUser(); |
| 2401 return WebInputEventResult::HandledSystem; |
| 2402 } |
| 2444 } else { | 2403 } else { |
| 2445 Node* stopNode = nullptr; | 2404 Node* stopNode = nullptr; |
| 2446 if (gestureEvent.preventPropagation()) | 2405 if (gestureEvent.preventPropagation()) |
| 2447 stopNode = m_previousGestureScrolledNode.get(); | 2406 stopNode = m_previousGestureScrolledNode.get(); |
| 2448 | 2407 |
| 2449 ScrollResult result = physicalScroll(granularity, delta, node, &stop
Node); | 2408 bool consumed = false; |
| 2450 | 2409 ScrollResult result = physicalScroll(granularity, delta, node, &stop
Node, consumed); |
| 2451 scrolled = result.didScroll(); | |
| 2452 | 2410 |
| 2453 if (gestureEvent.preventPropagation()) | 2411 if (gestureEvent.preventPropagation()) |
| 2454 m_previousGestureScrolledNode = stopNode; | 2412 m_previousGestureScrolledNode = stopNode; |
| 2455 | 2413 |
| 2456 resetOverscroll(result.didScrollX, result.didScrollY); | 2414 if (m_frame->isMainFrame() && (!stopNode || stopNode->layoutObject()
== m_frame->view()->layoutView())) { |
| 2457 } | 2415 FloatPoint position = FloatPoint(gestureEvent.position().x(), ge
stureEvent.position().y()); |
| 2458 if (scrolled) { | 2416 handleOverscroll(result, position, velocity); |
| 2459 setFrameWasScrolledByUser(); | 2417 } else { |
| 2460 return WebInputEventResult::HandledSystem; | 2418 resetOverscroll(result.didScrollX, result.didScrollY); |
| 2419 } |
| 2420 |
| 2421 if (consumed) |
| 2422 return WebInputEventResult::HandledSystem; |
| 2461 } | 2423 } |
| 2462 } | 2424 } |
| 2463 | 2425 |
| 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; | 2426 return WebInputEventResult::NotHandled; |
| 2479 } | 2427 } |
| 2480 | 2428 |
| 2481 void EventHandler::clearGestureScrollState() | 2429 void EventHandler::clearGestureScrollState() |
| 2482 { | 2430 { |
| 2483 m_scrollGestureHandlingNode = nullptr; | 2431 m_scrollGestureHandlingNode = nullptr; |
| 2484 m_previousGestureScrolledNode = nullptr; | 2432 m_previousGestureScrolledNode = nullptr; |
| 2485 m_deltaConsumedForScrollSequence = false; | 2433 m_deltaConsumedForScrollSequence = false; |
| 2486 m_currentScrollChain.clear(); | 2434 m_currentScrollChain.clear(); |
| 2487 m_accumulatedRootOverscroll = FloatSize(); | 2435 m_accumulatedRootOverscroll = FloatSize(); |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3427 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 3375 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
| 3428 return; | 3376 return; |
| 3429 | 3377 |
| 3430 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward
: ScrollBlockDirectionForward; | 3378 ScrollDirection direction = event->shiftKey() ? ScrollBlockDirectionBackward
: ScrollBlockDirectionForward; |
| 3431 | 3379 |
| 3432 // FIXME: enable scroll customization in this case. See crbug.com/410974. | 3380 // FIXME: enable scroll customization in this case. See crbug.com/410974. |
| 3433 if (logicalScroll(direction, ScrollByPage)) { | 3381 if (logicalScroll(direction, ScrollByPage)) { |
| 3434 event->setDefaultHandled(); | 3382 event->setDefaultHandled(); |
| 3435 return; | 3383 return; |
| 3436 } | 3384 } |
| 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 } | 3385 } |
| 3448 | 3386 |
| 3449 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) | 3387 void EventHandler::defaultBackspaceEventHandler(KeyboardEvent* event) |
| 3450 { | 3388 { |
| 3451 ASSERT(event->type() == EventTypeNames::keydown); | 3389 ASSERT(event->type() == EventTypeNames::keydown); |
| 3452 | 3390 |
| 3453 if (event->ctrlKey() || event->metaKey() || event->altKey()) | 3391 if (event->ctrlKey() || event->metaKey() || event->altKey()) |
| 3454 return; | 3392 return; |
| 3455 | 3393 |
| 3456 if (!m_frame->editor().behavior().shouldNavigateBackOnBackspace()) | 3394 if (!m_frame->editor().behavior().shouldNavigateBackOnBackspace()) |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3994 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 3932 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
| 3995 { | 3933 { |
| 3996 #if OS(MACOSX) | 3934 #if OS(MACOSX) |
| 3997 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); | 3935 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); |
| 3998 #else | 3936 #else |
| 3999 return PlatformEvent::AltKey; | 3937 return PlatformEvent::AltKey; |
| 4000 #endif | 3938 #endif |
| 4001 } | 3939 } |
| 4002 | 3940 |
| 4003 } // namespace blink | 3941 } // namespace blink |
| OLD | NEW |