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 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // TODO(bokan): This should be moved out into Chromium or removed if possibl e. | |
Rick Byers
2015/08/25 18:09:58
nit: now that the #if is gone, do you still even w
bokan
2015/08/25 18:13:45
Yah, I suppose it'd be cleaner to just have a "Pre
| |
1730 if (event.hasPreciseScrollingDeltas() && granularity == ScrollByPixel) | |
1731 granularity = ScrollByPrecisePixel; | |
1732 | |
1733 // If the event is a "PageWheelEvent" we should disregard the delta and | |
1734 // scroll by *one* page length per event. | |
1735 if (event.granularity() == ScrollByPageWheelEvent) { | |
1736 if (deltaX) | |
1737 deltaX = deltaX > 0 ? 1 : -1; | |
1738 if (deltaY) | |
1739 deltaY = deltaY > 0 ? 1 : -1; | |
1740 } | |
1741 | |
1742 // Positive delta is up and left. | |
1743 ScrollResultOneDimensional resultY = scrollableArea.userScroll(ScrollUp, gra nularity, deltaY); | |
1744 ScrollResultOneDimensional resultX = scrollableArea.userScroll(ScrollLeft, g ranularity, deltaX); | |
1745 | |
1746 ScrollResult result; | |
1747 result.didScrollY = resultY.didScroll; | |
1748 result.didScrollX = resultX.didScroll; | |
1749 result.unusedScrollDeltaY = resultY.unusedScrollDelta; | |
1750 result.unusedScrollDeltaX = resultX.unusedScrollDelta; | |
1751 return result; | |
1752 } | |
1753 | |
1754 } // namespace | |
1755 | |
1719 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event) | 1756 bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event) |
1720 { | 1757 { |
1721 #define RETURN_WHEEL_EVENT_HANDLED() \ | 1758 #define RETURN_WHEEL_EVENT_HANDLED() \ |
1722 { \ | 1759 { \ |
1723 setFrameWasScrolledByUser(); \ | 1760 setFrameWasScrolledByUser(); \ |
1724 return true; \ | 1761 return true; \ |
1725 } | 1762 } |
1726 | 1763 |
1727 Document* doc = m_frame->document(); | 1764 Document* doc = m_frame->document(); |
1728 | 1765 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1766 if (node && !node->dispatchWheelEvent(event)) | 1803 if (node && !node->dispatchWheelEvent(event)) |
1767 RETURN_WHEEL_EVENT_HANDLED(); | 1804 RETURN_WHEEL_EVENT_HANDLED(); |
1768 } | 1805 } |
1769 | 1806 |
1770 // We do another check on the frame view because the event handler can run | 1807 // We do another check on the frame view because the event handler can run |
1771 // JS which results in the frame getting destroyed. | 1808 // JS which results in the frame getting destroyed. |
1772 view = m_frame->view(); | 1809 view = m_frame->view(); |
1773 if (!view) | 1810 if (!view) |
1774 return false; | 1811 return false; |
1775 | 1812 |
1776 ScrollResult scrollResult = view->scrollableArea()->handleWheel(event); | 1813 // Wheel events which do not scroll are used to trigger zooming. |
1814 if (!event.canScroll()) | |
1815 return false; | |
1816 | |
1817 ScrollResult scrollResult = scrollAreaWithWheelEvent(event, *view->scrollabl eArea()); | |
1777 if (m_frame->settings() && m_frame->settings()->reportWheelOverscroll()) | 1818 if (m_frame->settings() && m_frame->settings()->reportWheelOverscroll()) |
1778 handleOverscroll(scrollResult); | 1819 handleOverscroll(scrollResult); |
1779 if (scrollResult.didScroll()) | 1820 if (scrollResult.didScroll()) |
1780 RETURN_WHEEL_EVENT_HANDLED(); | 1821 RETURN_WHEEL_EVENT_HANDLED(); |
1781 | 1822 |
1782 return false; | 1823 return false; |
1783 #undef RETURN_WHEEL_EVENT_HANDLED | 1824 #undef RETURN_WHEEL_EVENT_HANDLED |
1784 } | 1825 } |
1785 | 1826 |
1786 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) | 1827 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) |
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3996 unsigned EventHandler::accessKeyModifiers() | 4037 unsigned EventHandler::accessKeyModifiers() |
3997 { | 4038 { |
3998 #if OS(MACOSX) | 4039 #if OS(MACOSX) |
3999 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4040 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
4000 #else | 4041 #else |
4001 return PlatformEvent::AltKey; | 4042 return PlatformEvent::AltKey; |
4002 #endif | 4043 #endif |
4003 } | 4044 } |
4004 | 4045 |
4005 } // namespace blink | 4046 } // namespace blink |
OLD | NEW |