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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); | 865 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); |
866 | 866 |
867 // We always send hitTestResultAtPoint to the main frame if we have one, | 867 // We always send hitTestResultAtPoint to the main frame if we have one, |
868 // otherwise we might hit areas that are obscured by higher frames. | 868 // otherwise we might hit areas that are obscured by higher frames. |
869 if (m_frame->page()) { | 869 if (m_frame->page()) { |
870 LocalFrame* mainFrame = m_frame->localFrameRoot(); | 870 LocalFrame* mainFrame = m_frame->localFrameRoot(); |
871 if (mainFrame && m_frame != mainFrame) { | 871 if (mainFrame && m_frame != mainFrame) { |
872 FrameView* frameView = m_frame->view(); | 872 FrameView* frameView = m_frame->view(); |
873 FrameView* mainView = mainFrame->view(); | 873 FrameView* mainView = mainFrame->view(); |
874 if (frameView && mainView) { | 874 if (frameView && mainView) { |
875 IntPoint mainFramePoint = mainView->rootViewToContents(frameView
->contentsToRootView(roundedIntPoint(point))); | 875 IntPoint mainFramePoint = mainView->rootFrameToContents(frameVie
w->contentsToRootFrame(roundedIntPoint(point))); |
876 return mainFrame->eventHandler().hitTestResultAtPoint(mainFrameP
oint, hitType, padding); | 876 return mainFrame->eventHandler().hitTestResultAtPoint(mainFrameP
oint, hitType, padding); |
877 } | 877 } |
878 } | 878 } |
879 } | 879 } |
880 | 880 |
881 HitTestResult result(point, padding.height(), padding.width(), padding.heigh
t(), padding.width()); | 881 HitTestResult result(point, padding.height(), padding.width(), padding.heigh
t(), padding.width()); |
882 | 882 |
883 // RenderView::hitTest causes a layout, and we don't want to hit that until
the first | 883 // RenderView::hitTest causes a layout, and we don't want to hit that until
the first |
884 // layout because until then, there is nothing shown on the screen - the use
r can't | 884 // layout because until then, there is nothing shown on the screen - the use
r can't |
885 // have intentionally clicked on something belonging to this page. Furthermo
re, | 885 // have intentionally clicked on something belonging to this page. Furthermo
re, |
(...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2805 // Clear mouse press state to avoid initiating a drag while context menu is
up. | 2805 // Clear mouse press state to avoid initiating a drag while context menu is
up. |
2806 m_mousePressed = false; | 2806 m_mousePressed = false; |
2807 | 2807 |
2808 static const int kContextMenuMargin = 1; | 2808 static const int kContextMenuMargin = 1; |
2809 | 2809 |
2810 #if OS(WIN) | 2810 #if OS(WIN) |
2811 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); | 2811 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); |
2812 #else | 2812 #else |
2813 int rightAligned = 0; | 2813 int rightAligned = 0; |
2814 #endif | 2814 #endif |
2815 IntPoint rootViewLocation; | 2815 IntPoint locationInViewport; |
2816 Element* focusedElement = doc->focusedElement(); | 2816 Element* focusedElement = doc->focusedElement(); |
2817 FrameSelection& selection = m_frame->selection(); | 2817 FrameSelection& selection = m_frame->selection(); |
2818 Position start = selection.selection().start(); | 2818 Position start = selection.selection().start(); |
2819 | 2819 |
2820 if (start.deprecatedNode() && (selection.rootEditableElement() || selection.
isRange())) { | 2820 if (start.deprecatedNode() && (selection.rootEditableElement() || selection.
isRange())) { |
2821 RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange()
; | 2821 RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange()
; |
2822 IntRect firstRect = m_frame->editor().firstRectForRange(selectionRange.g
et()); | 2822 IntRect firstRect = m_frame->editor().firstRectForRange(selectionRange.g
et()); |
2823 | 2823 |
2824 int x = rightAligned ? firstRect.maxX() : firstRect.x(); | 2824 int x = rightAligned ? firstRect.maxX() : firstRect.x(); |
2825 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. | 2825 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. |
2826 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; | 2826 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; |
2827 rootViewLocation = view->contentsToRootView(IntPoint(x, y)); | 2827 locationInViewport = view->contentsToWindow(IntPoint(x, y)); |
2828 } else if (focusedElement) { | 2828 } else if (focusedElement) { |
2829 IntRect clippedRect = focusedElement->boundsInRootViewSpace(); | 2829 IntRect clippedRect = focusedElement->boundsInViewportSpace(); |
2830 rootViewLocation = IntPoint(clippedRect.center()); | 2830 locationInViewport = IntPoint(clippedRect.center()); |
2831 } else { | 2831 } else { |
2832 rootViewLocation = IntPoint( | 2832 // FIXME - Almost certainly wrong, this is not in viewport space. crbug.
com/458682. |
| 2833 locationInViewport = IntPoint( |
2833 rightAligned ? view->contentsWidth() - kContextMenuMargin : kContext
MenuMargin, | 2834 rightAligned ? view->contentsWidth() - kContextMenuMargin : kContext
MenuMargin, |
2834 kContextMenuMargin); | 2835 kContextMenuMargin); |
2835 } | 2836 } |
2836 | 2837 |
2837 m_frame->view()->setCursor(pointerCursor()); | 2838 m_frame->view()->setCursor(pointerCursor()); |
2838 IntPoint globalPosition = view->hostWindow()->rootViewToScreen(IntRect(rootV
iewLocation, IntSize())).location(); | 2839 IntPoint globalPosition = view->hostWindow()->viewportToScreen(IntRect(locat
ionInViewport, IntSize())).location(); |
2839 | 2840 |
2840 Node* targetNode = doc->focusedElement(); | 2841 Node* targetNode = doc->focusedElement(); |
2841 if (!targetNode) | 2842 if (!targetNode) |
2842 targetNode = doc; | 2843 targetNode = doc; |
2843 | 2844 |
2844 // Use the focused node as the target for hover and active. | 2845 // Use the focused node as the target for hover and active. |
2845 HitTestResult result(rootViewLocation); | 2846 HitTestResult result(locationInViewport); |
2846 result.setInnerNode(targetNode); | 2847 result.setInnerNode(targetNode); |
2847 doc->updateHoverActiveState(HitTestRequest::Active, result.innerElement()); | 2848 doc->updateHoverActiveState(HitTestRequest::Active, result.innerElement()); |
2848 | 2849 |
2849 // The contextmenu event is a mouse event even when invoked using the keyboa
rd. | 2850 // The contextmenu event is a mouse event even when invoked using the keyboa
rd. |
2850 // This is required for web compatibility. | 2851 // This is required for web compatibility. |
2851 PlatformEvent::Type eventType = PlatformEvent::MousePressed; | 2852 PlatformEvent::Type eventType = PlatformEvent::MousePressed; |
2852 if (m_frame->settings()->showContextMenuOnMouseUp()) | 2853 if (m_frame->settings()->showContextMenuOnMouseUp()) |
2853 eventType = PlatformEvent::MouseReleased; | 2854 eventType = PlatformEvent::MouseReleased; |
2854 | 2855 |
2855 PlatformMouseEvent mouseEvent(rootViewLocation, globalPosition, RightButton,
eventType, 1, false, false, false, false, PlatformMouseEvent::RealOrIndistingui
shable, WTF::currentTime()); | 2856 PlatformMouseEvent mouseEvent(locationInViewport, globalPosition, RightButto
n, eventType, 1, false, false, false, false, PlatformMouseEvent::RealOrIndisting
uishable, WTF::currentTime()); |
2856 | 2857 |
2857 handleMousePressEvent(mouseEvent); | 2858 handleMousePressEvent(mouseEvent); |
2858 return sendContextMenuEvent(mouseEvent); | 2859 return sendContextMenuEvent(mouseEvent); |
2859 } | 2860 } |
2860 | 2861 |
2861 bool EventHandler::sendContextMenuEventForGesture(const GestureEventWithHitTestR
esults& targetedEvent) | 2862 bool EventHandler::sendContextMenuEventForGesture(const GestureEventWithHitTestR
esults& targetedEvent) |
2862 { | 2863 { |
2863 unsigned modifiers = targetedEvent.event().modifiers(); | 2864 unsigned modifiers = targetedEvent.event().modifiers(); |
2864 PlatformEvent::Type eventType = PlatformEvent::MousePressed; | 2865 PlatformEvent::Type eventType = PlatformEvent::MousePressed; |
2865 | 2866 |
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3902 unsigned EventHandler::accessKeyModifiers() | 3903 unsigned EventHandler::accessKeyModifiers() |
3903 { | 3904 { |
3904 #if OS(MACOSX) | 3905 #if OS(MACOSX) |
3905 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3906 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3906 #else | 3907 #else |
3907 return PlatformEvent::AltKey; | 3908 return PlatformEvent::AltKey; |
3908 #endif | 3909 #endif |
3909 } | 3910 } |
3910 | 3911 |
3911 } // namespace blink | 3912 } // namespace blink |
OLD | NEW |