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

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

Issue 1298973004: Remove special wheel handling path from ScrollableArea (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 Element* next = page->focusController().findFocusableElement(WebFocusTyp eForward, *element.authorShadowRoot()); 1709 Element* next = page->focusController().findFocusableElement(WebFocusTyp eForward, *element.authorShadowRoot());
1710 if (next && element.containsIncludingShadowDOM(next)) { 1710 if (next && element.containsIncludingShadowDOM(next)) {
1711 // Use WebFocusTypeForward instead of WebFocusTypeMouse here to mean the focus has slided. 1711 // Use WebFocusTypeForward instead of WebFocusTypeMouse here to mean the focus has slided.
1712 next->focus(false, WebFocusTypeForward); 1712 next->focus(false, WebFocusTypeForward);
1713 return true; 1713 return true;
1714 } 1714 }
1715 } 1715 }
1716 return false; 1716 return false;
1717 } 1717 }
1718 1718
1719 namespace {
1720
1721 ScrollResult scrollAreaWithWheelEvent(const PlatformWheelEvent& event, Scrollabl eArea& scrollableArea)
1722 {
1723 float deltaX = event.railsMode() != PlatformEvent::RailsModeVertical ? event .deltaX() : 0;
1724 float deltaY = event.railsMode() != PlatformEvent::RailsModeHorizontal ? eve nt.deltaY() : 0;
1725
1726 ScrollGranularity granularity =
1727 event.granularity() == ScrollByPixelWheelEvent ? ScrollByPixel : ScrollB yPage;
1728
1729 #if !OS(MACOSX)
1730 if (event.hasPreciseScrollingDeltas() && granularity == ScrollByPixel)
1731 granularity = ScrollByPrecisePixel;
Rick Byers 2015/08/19 17:33:31 why do we need this? Should be handled up in chro
bokan 2015/08/19 18:45:46 I don't understand this well but I moved it from S
1732 #endif
1733
1734 // If the event is a "PageWheelEvent" we should disregard the delta and
1735 // scroll by *one* page length per event.
1736 if (event.granularity() == ScrollByPageWheelEvent) {
1737 if (deltaX)
1738 deltaX = deltaX > 0 ? 1 : -1;
1739 if (deltaY)
1740 deltaY = deltaY > 0 ? 1 : -1;
1741 }
1742
1743 // Positive delta is up and left.
1744 ScrollResultOneDimensional resultY = scrollableArea.userScroll(ScrollUp, gra nularity, deltaY);
1745 ScrollResultOneDimensional resultX = scrollableArea.userScroll(ScrollLeft, g ranularity, deltaX);
1746
1747 ScrollResult result;
1748 result.didScrollY = resultY.didScroll;
1749 result.didScrollX = resultX.didScroll;
1750 result.unusedScrollDeltaY = resultY.unusedScrollDelta;
1751 result.unusedScrollDeltaX = resultX.unusedScrollDelta;
1752 return result;
1753 }
1754
1755 } // namespace
1756
1719 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event) 1757 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event)
1720 { 1758 {
1721 #define RETURN_WHEEL_EVENT_HANDLED() \ 1759 #define RETURN_WHEEL_EVENT_HANDLED() \
1722 { \ 1760 { \
1723 setFrameWasScrolledByUser(); \ 1761 setFrameWasScrolledByUser(); \
1724 return true; \ 1762 return true; \
1725 } 1763 }
1726 1764
1727 Document* doc = m_frame->document(); 1765 Document* doc = m_frame->document();
1728 1766
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 if (node && !node->dispatchWheelEvent(event)) 1804 if (node && !node->dispatchWheelEvent(event))
1767 RETURN_WHEEL_EVENT_HANDLED(); 1805 RETURN_WHEEL_EVENT_HANDLED();
1768 } 1806 }
1769 1807
1770 // We do another check on the frame view because the event handler can run 1808 // We do another check on the frame view because the event handler can run
1771 // JS which results in the frame getting destroyed. 1809 // JS which results in the frame getting destroyed.
1772 view = m_frame->view(); 1810 view = m_frame->view();
1773 if (!view) 1811 if (!view)
1774 return false; 1812 return false;
1775 1813
1776 ScrollResult scrollResult = view->scrollableArea()->handleWheel(event); 1814 // Wheel events which do not scroll are used to trigger zooming.
1815 if (!event.canScroll())
1816 return false;
1817
1818 ScrollResult scrollResult = scrollAreaWithWheelEvent(event, *view->scrollabl eArea());
1777 if (m_frame->settings() && m_frame->settings()->reportWheelOverscroll()) 1819 if (m_frame->settings() && m_frame->settings()->reportWheelOverscroll())
1778 handleOverscroll(scrollResult); 1820 handleOverscroll(scrollResult);
1779 if (scrollResult.didScroll()) 1821 if (scrollResult.didScroll())
1780 RETURN_WHEEL_EVENT_HANDLED(); 1822 RETURN_WHEEL_EVENT_HANDLED();
1781 1823
1782 return false; 1824 return false;
1783 #undef RETURN_WHEEL_EVENT_HANDLED 1825 #undef RETURN_WHEEL_EVENT_HANDLED
1784 } 1826 }
1785 1827
1786 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) 1828 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent)
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3996 unsigned EventHandler::accessKeyModifiers() 4038 unsigned EventHandler::accessKeyModifiers()
3997 { 4039 {
3998 #if OS(MACOSX) 4040 #if OS(MACOSX)
3999 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 4041 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4000 #else 4042 #else
4001 return PlatformEvent::AltKey; 4043 return PlatformEvent::AltKey;
4002 #endif 4044 #endif
4003 } 4045 }
4004 4046
4005 } // namespace blink 4047 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698