| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 | 1795 |
| 1796 GetSelectionController().SendContextMenuEvent(mev, position_in_contents); | 1796 GetSelectionController().SendContextMenuEvent(mev, position_in_contents); |
| 1797 | 1797 |
| 1798 Node* target_node = | 1798 Node* target_node = |
| 1799 override_target_node ? override_target_node : mev.InnerNode(); | 1799 override_target_node ? override_target_node : mev.InnerNode(); |
| 1800 return mouse_event_manager_->DispatchMouseEvent( | 1800 return mouse_event_manager_->DispatchMouseEvent( |
| 1801 UpdateMouseEventTargetNode(target_node), EventTypeNames::contextmenu, | 1801 UpdateMouseEventTargetNode(target_node), EventTypeNames::contextmenu, |
| 1802 event, mev.GetHitTestResult().CanvasRegionId(), 0); | 1802 event, mev.GetHitTestResult().CanvasRegionId(), 0); |
| 1803 } | 1803 } |
| 1804 | 1804 |
| 1805 static bool ShouldShowContextMenuAtSelection(const FrameSelection& selection) { |
| 1806 const VisibleSelection& visible_selection = |
| 1807 selection.ComputeVisibleSelectionInDOMTreeDeprecated(); |
| 1808 if (!visible_selection.IsRange() && !visible_selection.RootEditableElement()) |
| 1809 return false; |
| 1810 return selection.SelectionHasFocus(); |
| 1811 } |
| 1812 |
| 1805 WebInputEventResult EventHandler::SendContextMenuEventForKey( | 1813 WebInputEventResult EventHandler::SendContextMenuEventForKey( |
| 1806 Element* override_target_element) { | 1814 Element* override_target_element) { |
| 1807 FrameView* view = frame_->View(); | 1815 FrameView* view = frame_->View(); |
| 1808 if (!view) | 1816 if (!view) |
| 1809 return WebInputEventResult::kNotHandled; | 1817 return WebInputEventResult::kNotHandled; |
| 1810 | 1818 |
| 1811 Document* doc = frame_->GetDocument(); | 1819 Document* doc = frame_->GetDocument(); |
| 1812 if (!doc) | 1820 if (!doc) |
| 1813 return WebInputEventResult::kNotHandled; | 1821 return WebInputEventResult::kNotHandled; |
| 1814 | 1822 |
| 1815 static const int kContextMenuMargin = 1; | 1823 static const int kContextMenuMargin = 1; |
| 1816 | 1824 |
| 1817 #if OS(WIN) | 1825 #if OS(WIN) |
| 1818 int right_aligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); | 1826 int right_aligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT); |
| 1819 #else | 1827 #else |
| 1820 int right_aligned = 0; | 1828 int right_aligned = 0; |
| 1821 #endif | 1829 #endif |
| 1822 IntPoint location_in_root_frame; | 1830 IntPoint location_in_root_frame; |
| 1823 | 1831 |
| 1824 Element* focused_element = | 1832 Element* focused_element = |
| 1825 override_target_element ? override_target_element : doc->FocusedElement(); | 1833 override_target_element ? override_target_element : doc->FocusedElement(); |
| 1826 FrameSelection& selection = frame_->Selection(); | 1834 FrameSelection& selection = frame_->Selection(); |
| 1827 Position start = | |
| 1828 selection.ComputeVisibleSelectionInDOMTreeDeprecated().Start(); | |
| 1829 VisualViewport& visual_viewport = frame_->GetPage()->GetVisualViewport(); | 1835 VisualViewport& visual_viewport = frame_->GetPage()->GetVisualViewport(); |
| 1830 | 1836 |
| 1831 if (!override_target_element && start.AnchorNode() && !selection.IsHidden() && | 1837 if (!override_target_element && ShouldShowContextMenuAtSelection(selection)) { |
| 1832 (selection.ComputeVisibleSelectionInDOMTreeDeprecated() | |
| 1833 .RootEditableElement() || | |
| 1834 selection.ComputeVisibleSelectionInDOMTreeDeprecated().IsRange())) { | |
| 1835 // TODO(editing-dev): Use of updateStyleAndLayoutIgnorePendingStylesheets | 1838 // TODO(editing-dev): Use of updateStyleAndLayoutIgnorePendingStylesheets |
| 1836 // needs to be audited. See http://crbug.com/590369 for more details. | 1839 // needs to be audited. See http://crbug.com/590369 for more details. |
| 1837 doc->UpdateStyleAndLayoutIgnorePendingStylesheets(); | 1840 doc->UpdateStyleAndLayoutIgnorePendingStylesheets(); |
| 1838 | 1841 |
| 1839 IntRect first_rect = frame_->GetEditor().FirstRectForRange( | 1842 IntRect first_rect = frame_->GetEditor().FirstRectForRange( |
| 1840 selection.ComputeVisibleSelectionInDOMTree() | 1843 selection.ComputeVisibleSelectionInDOMTree() |
| 1841 .ToNormalizedEphemeralRange()); | 1844 .ToNormalizedEphemeralRange()); |
| 1842 | 1845 |
| 1843 int x = right_aligned ? first_rect.MaxX() : first_rect.X(); | 1846 int x = right_aligned ? first_rect.MaxX() : first_rect.X(); |
| 1844 // In a multiline edit, firstRect.maxY() would end up on the next line, so | 1847 // In a multiline edit, firstRect.maxY() would end up on the next line, so |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2119 MouseEventWithHitTestResults& mev, | 2122 MouseEventWithHitTestResults& mev, |
| 2120 LocalFrame* subframe) { | 2123 LocalFrame* subframe) { |
| 2121 WebInputEventResult result = | 2124 WebInputEventResult result = |
| 2122 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); | 2125 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); |
| 2123 if (result != WebInputEventResult::kNotHandled) | 2126 if (result != WebInputEventResult::kNotHandled) |
| 2124 return result; | 2127 return result; |
| 2125 return WebInputEventResult::kHandledSystem; | 2128 return WebInputEventResult::kHandledSystem; |
| 2126 } | 2129 } |
| 2127 | 2130 |
| 2128 } // namespace blink | 2131 } // namespace blink |
| OLD | NEW |