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 2771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 // Clear mouse press state to avoid initiating a drag while context menu is
up. | 2782 // Clear mouse press state to avoid initiating a drag while context menu is
up. |
2783 m_mousePressed = false; | 2783 m_mousePressed = false; |
2784 | 2784 |
2785 static const int kContextMenuMargin = 1; | 2785 static const int kContextMenuMargin = 1; |
2786 | 2786 |
2787 #if OS(WIN) | 2787 #if OS(WIN) |
2788 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); | 2788 int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); |
2789 #else | 2789 #else |
2790 int rightAligned = 0; | 2790 int rightAligned = 0; |
2791 #endif | 2791 #endif |
2792 IntPoint location; | 2792 IntPoint rootViewLocation; |
2793 | |
2794 Element* focusedElement = doc->focusedElement(); | 2793 Element* focusedElement = doc->focusedElement(); |
2795 FrameSelection& selection = m_frame->selection(); | 2794 FrameSelection& selection = m_frame->selection(); |
2796 Position start = selection.selection().start(); | 2795 Position start = selection.selection().start(); |
2797 bool shouldTranslateToRootView = true; | |
2798 | 2796 |
2799 if (start.deprecatedNode() && (selection.rootEditableElement() || selection.
isRange())) { | 2797 if (start.deprecatedNode() && (selection.rootEditableElement() || selection.
isRange())) { |
2800 RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange()
; | 2798 RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange()
; |
2801 IntRect firstRect = m_frame->editor().firstRectForRange(selectionRange.g
et()); | 2799 IntRect firstRect = m_frame->editor().firstRectForRange(selectionRange.g
et()); |
2802 | 2800 |
2803 int x = rightAligned ? firstRect.maxX() : firstRect.x(); | 2801 int x = rightAligned ? firstRect.maxX() : firstRect.x(); |
2804 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. | 2802 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. |
2805 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; | 2803 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; |
2806 location = IntPoint(x, y); | 2804 rootViewLocation = view->contentsToRootView(IntPoint(x, y)); |
2807 } else if (focusedElement) { | 2805 } else if (focusedElement) { |
2808 IntRect clippedRect = focusedElement->boundsInRootViewSpace(); | 2806 IntRect clippedRect = focusedElement->boundsInRootViewSpace(); |
2809 location = IntPoint(clippedRect.center()); | 2807 rootViewLocation = IntPoint(clippedRect.center()); |
2810 } else { | 2808 } else { |
2811 location = IntPoint( | 2809 rootViewLocation = IntPoint( |
2812 rightAligned ? view->contentsWidth() - kContextMenuMargin : kContext
MenuMargin, | 2810 rightAligned ? view->contentsWidth() - kContextMenuMargin : kContext
MenuMargin, |
2813 kContextMenuMargin); | 2811 kContextMenuMargin); |
2814 shouldTranslateToRootView = false; | |
2815 } | 2812 } |
2816 | 2813 |
2817 m_frame->view()->setCursor(pointerCursor()); | 2814 m_frame->view()->setCursor(pointerCursor()); |
2818 | 2815 IntPoint globalPosition = view->hostWindow()->rootViewToScreen(IntRect(rootV
iewLocation, IntSize())).location(); |
2819 IntPoint position = shouldTranslateToRootView ? view->contentsToRootView(loc
ation) : location; | |
2820 IntPoint globalPosition = view->hostWindow()->rootViewToScreen(IntRect(posit
ion, IntSize())).location(); | |
2821 | 2816 |
2822 Node* targetNode = doc->focusedElement(); | 2817 Node* targetNode = doc->focusedElement(); |
2823 if (!targetNode) | 2818 if (!targetNode) |
2824 targetNode = doc; | 2819 targetNode = doc; |
2825 | 2820 |
2826 // Use the focused node as the target for hover and active. | 2821 // Use the focused node as the target for hover and active. |
2827 HitTestResult result(position); | 2822 HitTestResult result(rootViewLocation); |
2828 result.setInnerNode(targetNode); | 2823 result.setInnerNode(targetNode); |
2829 doc->updateHoverActiveState(HitTestRequest::Active, result.innerElement()); | 2824 doc->updateHoverActiveState(HitTestRequest::Active, result.innerElement()); |
2830 | 2825 |
2831 // The contextmenu event is a mouse event even when invoked using the keyboa
rd. | 2826 // The contextmenu event is a mouse event even when invoked using the keyboa
rd. |
2832 // This is required for web compatibility. | 2827 // This is required for web compatibility. |
2833 PlatformEvent::Type eventType = PlatformEvent::MousePressed; | 2828 PlatformEvent::Type eventType = PlatformEvent::MousePressed; |
2834 if (m_frame->settings()->showContextMenuOnMouseUp()) | 2829 if (m_frame->settings()->showContextMenuOnMouseUp()) |
2835 eventType = PlatformEvent::MouseReleased; | 2830 eventType = PlatformEvent::MouseReleased; |
2836 | 2831 |
2837 PlatformMouseEvent mouseEvent(position, globalPosition, RightButton, eventTy
pe, 1, false, false, false, false, PlatformMouseEvent::RealOrIndistinguishable,
WTF::currentTime()); | 2832 PlatformMouseEvent mouseEvent(rootViewLocation, globalPosition, RightButton,
eventType, 1, false, false, false, false, PlatformMouseEvent::RealOrIndistingui
shable, WTF::currentTime()); |
2838 | 2833 |
2839 handleMousePressEvent(mouseEvent); | 2834 handleMousePressEvent(mouseEvent); |
2840 return sendContextMenuEvent(mouseEvent); | 2835 return sendContextMenuEvent(mouseEvent); |
2841 } | 2836 } |
2842 | 2837 |
2843 bool EventHandler::sendContextMenuEventForGesture(const GestureEventWithHitTestR
esults& targetedEvent) | 2838 bool EventHandler::sendContextMenuEventForGesture(const GestureEventWithHitTestR
esults& targetedEvent) |
2844 { | 2839 { |
2845 unsigned modifiers = targetedEvent.event().modifiers(); | 2840 unsigned modifiers = targetedEvent.event().modifiers(); |
2846 PlatformEvent::Type eventType = PlatformEvent::MousePressed; | 2841 PlatformEvent::Type eventType = PlatformEvent::MousePressed; |
2847 | 2842 |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3889 unsigned EventHandler::accessKeyModifiers() | 3884 unsigned EventHandler::accessKeyModifiers() |
3890 { | 3885 { |
3891 #if OS(MACOSX) | 3886 #if OS(MACOSX) |
3892 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3887 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3893 #else | 3888 #else |
3894 return PlatformEvent::AltKey; | 3889 return PlatformEvent::AltKey; |
3895 #endif | 3890 #endif |
3896 } | 3891 } |
3897 | 3892 |
3898 } // namespace blink | 3893 } // namespace blink |
OLD | NEW |