OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "web/ExternalPopupMenu.h" | 31 #include "web/ExternalPopupMenu.h" |
32 | 32 |
33 #include "core/dom/NodeComputedStyle.h" | 33 #include "core/dom/NodeComputedStyle.h" |
34 #include "core/dom/TaskRunnerHelper.h" | 34 #include "core/dom/TaskRunnerHelper.h" |
| 35 #include "core/exported/WebViewBase.h" |
35 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
36 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
37 #include "core/html/HTMLOptionElement.h" | 38 #include "core/html/HTMLOptionElement.h" |
38 #include "core/html/HTMLSelectElement.h" | 39 #include "core/html/HTMLSelectElement.h" |
39 #include "core/layout/LayoutBox.h" | 40 #include "core/layout/LayoutBox.h" |
40 #include "core/page/Page.h" | 41 #include "core/page/Page.h" |
41 #include "core/style/ComputedStyle.h" | 42 #include "core/style/ComputedStyle.h" |
42 #include "platform/geometry/FloatQuad.h" | 43 #include "platform/geometry/FloatQuad.h" |
43 #include "platform/geometry/IntPoint.h" | 44 #include "platform/geometry/IntPoint.h" |
44 #include "platform/text/TextDirection.h" | 45 #include "platform/text/TextDirection.h" |
45 #include "platform/wtf/PtrUtil.h" | 46 #include "platform/wtf/PtrUtil.h" |
| 47 #include "public/platform/WebCoalescedInputEvent.h" |
46 #include "public/platform/WebMouseEvent.h" | 48 #include "public/platform/WebMouseEvent.h" |
47 #include "public/platform/WebVector.h" | 49 #include "public/platform/WebVector.h" |
48 #include "public/web/WebExternalPopupMenu.h" | 50 #include "public/web/WebExternalPopupMenu.h" |
49 #include "public/web/WebFrameClient.h" | 51 #include "public/web/WebFrameClient.h" |
50 #include "public/web/WebMenuItemInfo.h" | 52 #include "public/web/WebMenuItemInfo.h" |
51 #include "public/web/WebPopupMenuInfo.h" | 53 #include "public/web/WebPopupMenuInfo.h" |
| 54 #include "public/web/WebView.h" |
52 #include "web/WebLocalFrameImpl.h" | 55 #include "web/WebLocalFrameImpl.h" |
53 #include "web/WebViewImpl.h" | |
54 | 56 |
55 namespace blink { | 57 namespace blink { |
56 | 58 |
57 ExternalPopupMenu::ExternalPopupMenu(LocalFrame& frame, | 59 ExternalPopupMenu::ExternalPopupMenu(LocalFrame& frame, |
58 HTMLSelectElement& owner_element, | 60 HTMLSelectElement& owner_element, |
59 WebViewImpl& web_view) | 61 WebView& web_view) |
60 : owner_element_(owner_element), | 62 : owner_element_(owner_element), |
61 local_frame_(frame), | 63 local_frame_(frame), |
62 web_view_(web_view), | 64 web_view_(web_view), |
63 dispatch_event_timer_( | 65 dispatch_event_timer_( |
64 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &frame), | 66 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &frame), |
65 this, | 67 this, |
66 &ExternalPopupMenu::DispatchEvent), | 68 &ExternalPopupMenu::DispatchEvent), |
67 web_external_popup_menu_(0) {} | 69 web_external_popup_menu_(0) {} |
68 | 70 |
69 ExternalPopupMenu::~ExternalPopupMenu() {} | 71 ExternalPopupMenu::~ExternalPopupMenu() {} |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // pending to be shown for example). | 108 // pending to be shown for example). |
107 DidCancel(); | 109 DidCancel(); |
108 return false; | 110 return false; |
109 } | 111 } |
110 } | 112 } |
111 | 113 |
112 void ExternalPopupMenu::Show() { | 114 void ExternalPopupMenu::Show() { |
113 if (!ShowInternal()) | 115 if (!ShowInternal()) |
114 return; | 116 return; |
115 #if OS(MACOSX) | 117 #if OS(MACOSX) |
116 const WebInputEvent* current_event = WebViewImpl::CurrentInputEvent(); | 118 const WebInputEvent* current_event = WebViewBase::CurrentInputEvent(); |
117 if (current_event && current_event->GetType() == WebInputEvent::kMouseDown) { | 119 if (current_event && current_event->GetType() == WebInputEvent::kMouseDown) { |
118 synthetic_event_ = WTF::WrapUnique(new WebMouseEvent); | 120 synthetic_event_ = WTF::WrapUnique(new WebMouseEvent); |
119 *synthetic_event_ = *static_cast<const WebMouseEvent*>(current_event); | 121 *synthetic_event_ = *static_cast<const WebMouseEvent*>(current_event); |
120 synthetic_event_->SetType(WebInputEvent::kMouseUp); | 122 synthetic_event_->SetType(WebInputEvent::kMouseUp); |
121 dispatch_event_timer_.StartOneShot(0, BLINK_FROM_HERE); | 123 dispatch_event_timer_.StartOneShot(0, BLINK_FROM_HERE); |
122 // FIXME: show() is asynchronous. If preparing a popup is slow and a | 124 // FIXME: show() is asynchronous. If preparing a popup is slow and a |
123 // user released the mouse button before showing the popup, mouseup and | 125 // user released the mouse button before showing the popup, mouseup and |
124 // click events are correctly dispatched. Dispatching the synthetic | 126 // click events are correctly dispatched. Dispatching the synthetic |
125 // mouseup event is redundant in this case. | 127 // mouseup event is redundant in this case. |
126 } | 128 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 if (owner_element.ItemIsDisplayNone(*items[i])) | 306 if (owner_element.ItemIsDisplayNone(*items[i])) |
305 continue; | 307 continue; |
306 if (popup_menu_item_index == i) | 308 if (popup_menu_item_index == i) |
307 return index_tracker; | 309 return index_tracker; |
308 ++index_tracker; | 310 ++index_tracker; |
309 } | 311 } |
310 return -1; | 312 return -1; |
311 } | 313 } |
312 | 314 |
313 } // namespace blink | 315 } // namespace blink |
OLD | NEW |