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 2941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2952 | 2952 |
2953 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event) | 2953 bool EventHandler::sendContextMenuEvent(const PlatformMouseEvent& event) |
2954 { | 2954 { |
2955 Document* doc = m_frame->document(); | 2955 Document* doc = m_frame->document(); |
2956 FrameView* v = m_frame->view(); | 2956 FrameView* v = m_frame->view(); |
2957 if (!v) | 2957 if (!v) |
2958 return false; | 2958 return false; |
2959 | 2959 |
2960 // Clear mouse press state to avoid initiating a drag while context menu is
up. | 2960 // Clear mouse press state to avoid initiating a drag while context menu is
up. |
2961 m_mousePressed = false; | 2961 m_mousePressed = false; |
2962 LayoutPoint viewportPos = v->rootFrameToContents(event.position()); | 2962 LayoutPoint positionInContents = v->rootFrameToContents(event.position()); |
2963 HitTestRequest request(HitTestRequest::Active); | 2963 HitTestRequest request(HitTestRequest::Active); |
2964 MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, viewportP
os, event); | 2964 MouseEventWithHitTestResults mev = doc->prepareMouseEvent(request, positionI
nContents, event); |
2965 | 2965 |
2966 if (!m_frame->selection().contains(viewportPos) | 2966 if (!m_frame->selection().contains(positionInContents) |
2967 && !mev.scrollbar() | 2967 && !mev.scrollbar() |
2968 // FIXME: In the editable case, word selection sometimes selects content
that isn't underneath the mouse. | 2968 // FIXME: In the editable case, word selection sometimes selects content
that isn't underneath the mouse. |
2969 // If the selection is non-editable, we do word selection to make it eas
ier to use the contextual menu items | 2969 // If the selection is non-editable, we do word selection to make it eas
ier to use the contextual menu items |
2970 // available for text selections. But only if we're above text. | 2970 // available for text selections. But only if we're above text. |
2971 && (m_frame->selection().isContentEditable() || (mev.innerNode() && mev.
innerNode()->isTextNode()))) { | 2971 && (m_frame->selection().isContentEditable() || (mev.innerNode() && mev.
innerNode()->isTextNode()))) { |
2972 m_mouseDownMayStartSelect = true; // context menu events are always allo
wed to perform a selection | 2972 m_mouseDownMayStartSelect = true; // context menu events are always allo
wed to perform a selection |
2973 | 2973 |
2974 if (mev.hitTestResult().isMisspelled()) | 2974 if (mev.hitTestResult().isMisspelled()) |
2975 selectClosestMisspellingFromMouseEvent(mev); | 2975 selectClosestMisspellingFromMouseEvent(mev); |
2976 else if (m_frame->editor().behavior().shouldSelectOnContextualMenuClick(
)) | 2976 else if (m_frame->editor().behavior().shouldSelectOnContextualMenuClick(
)) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3014 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. | 3014 // In a multiline edit, firstRect.maxY() would endup on the next line, s
o -1. |
3015 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; | 3015 int y = firstRect.maxY() ? firstRect.maxY() - 1 : 0; |
3016 locationInRootFrame = view->contentsToRootFrame(IntPoint(x, y)); | 3016 locationInRootFrame = view->contentsToRootFrame(IntPoint(x, y)); |
3017 } else if (focusedElement) { | 3017 } else if (focusedElement) { |
3018 IntRect clippedRect = focusedElement->boundsInViewportSpace(); | 3018 IntRect clippedRect = focusedElement->boundsInViewportSpace(); |
3019 // FIXME: boundsInViewportSpace is actually in the weird scaled but untr
anslated coordinate space of | 3019 // FIXME: boundsInViewportSpace is actually in the weird scaled but untr
anslated coordinate space of |
3020 // the old-style pinch viewport. crbug.com/459591. | 3020 // the old-style pinch viewport. crbug.com/459591. |
3021 locationInRootFrame = flooredIntPoint(pinchViewport.viewportCSSPixelsToR
ootFrame(clippedRect.center())); | 3021 locationInRootFrame = flooredIntPoint(pinchViewport.viewportCSSPixelsToR
ootFrame(clippedRect.center())); |
3022 } else { | 3022 } else { |
3023 locationInRootFrame = IntPoint( | 3023 locationInRootFrame = IntPoint( |
3024 rightAligned ? pinchViewport.visibleRect().maxX() - kContextMenuMarg
in : kContextMenuMargin, | 3024 rightAligned |
3025 kContextMenuMargin); | 3025 ? pinchViewport.visibleRect().maxX() - kContextMenuMargin |
| 3026 : pinchViewport.location().x() + kContextMenuMargin, |
| 3027 pinchViewport.location().y() + kContextMenuMargin); |
3026 } | 3028 } |
3027 | 3029 |
3028 m_frame->view()->setCursor(pointerCursor()); | 3030 m_frame->view()->setCursor(pointerCursor()); |
3029 IntPoint locationInViewport = pinchViewport.rootFrameToViewport(locationInRo
otFrame); | 3031 IntPoint locationInViewport = pinchViewport.rootFrameToViewport(locationInRo
otFrame); |
3030 IntPoint globalPosition = view->hostWindow()->viewportToScreen(IntRect(locat
ionInViewport, IntSize())).location(); | 3032 IntPoint globalPosition = view->hostWindow()->viewportToScreen(IntRect(locat
ionInViewport, IntSize())).location(); |
3031 | 3033 |
3032 Node* targetNode = doc->focusedElement(); | 3034 Node* targetNode = doc->focusedElement(); |
3033 if (!targetNode) | 3035 if (!targetNode) |
3034 targetNode = doc; | 3036 targetNode = doc; |
3035 | 3037 |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4082 unsigned EventHandler::accessKeyModifiers() | 4084 unsigned EventHandler::accessKeyModifiers() |
4083 { | 4085 { |
4084 #if OS(MACOSX) | 4086 #if OS(MACOSX) |
4085 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4087 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
4086 #else | 4088 #else |
4087 return PlatformEvent::AltKey; | 4089 return PlatformEvent::AltKey; |
4088 #endif | 4090 #endif |
4089 } | 4091 } |
4090 | 4092 |
4091 } // namespace blink | 4093 } // namespace blink |
OLD | NEW |