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