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