Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: Source/web/ExternalPopupMenu.cpp

Issue 118453006: Mac: Send a synthetic mouseup event when <select> popup menu is opened. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/ExternalPopupMenu.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
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 "config.h" 31 #include "config.h"
32 #include "ExternalPopupMenu.h" 32 #include "ExternalPopupMenu.h"
33 33
34 #include "WebExternalPopupMenu.h" 34 #include "WebExternalPopupMenu.h"
35 #include "WebMenuItemInfo.h" 35 #include "WebMenuItemInfo.h"
36 #include "WebPopupMenuInfo.h" 36 #include "WebPopupMenuInfo.h"
37 #include "WebViewClient.h" 37 #include "WebViewClient.h"
38 #include "WebViewImpl.h"
38 #include "core/frame/Frame.h" 39 #include "core/frame/Frame.h"
39 #include "core/frame/FrameView.h" 40 #include "core/frame/FrameView.h"
40 #include "platform/PopupMenuClient.h" 41 #include "platform/PopupMenuClient.h"
41 #include "platform/geometry/FloatQuad.h" 42 #include "platform/geometry/FloatQuad.h"
42 #include "platform/geometry/IntPoint.h" 43 #include "platform/geometry/IntPoint.h"
43 #include "platform/text/TextDirection.h" 44 #include "platform/text/TextDirection.h"
44 #include "public/platform/WebVector.h" 45 #include "public/platform/WebVector.h"
45 46
46 using namespace WebCore; 47 using namespace WebCore;
47 48
48 namespace blink { 49 namespace blink {
49 50
50 ExternalPopupMenu::ExternalPopupMenu(Frame& frame, PopupMenuClient* popupMenuCli ent, WebViewClient* webViewClient) 51 ExternalPopupMenu::ExternalPopupMenu(Frame& frame, PopupMenuClient* popupMenuCli ent, WebViewImpl& webView)
51 : m_popupMenuClient(popupMenuClient) 52 : m_popupMenuClient(popupMenuClient)
52 , m_frameView(frame.view()) 53 , m_frameView(frame.view())
53 , m_webViewClient(webViewClient) 54 , m_webView(webView)
55 , m_dispatchEventTimer(this, &ExternalPopupMenu::dispatchEvent)
54 , m_webExternalPopupMenu(0) 56 , m_webExternalPopupMenu(0)
55 { 57 {
56 } 58 }
57 59
58 ExternalPopupMenu::~ExternalPopupMenu() 60 ExternalPopupMenu::~ExternalPopupMenu()
59 { 61 {
60 } 62 }
61 63
62 void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, i nt index) 64 void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, i nt index)
63 { 65 {
64 IntRect rect(controlPosition.enclosingBoundingBox()); 66 IntRect rect(controlPosition.enclosingBoundingBox());
65 // WebCore reuses the PopupMenu of a page. 67 // WebCore reuses the PopupMenu of a page.
66 // For simplicity, we do recreate the actual external popup everytime. 68 // For simplicity, we do recreate the actual external popup everytime.
67 hide(); 69 hide();
68 70
69 WebPopupMenuInfo info; 71 WebPopupMenuInfo info;
70 getPopupMenuInfo(&info); 72 getPopupMenuInfo(&info);
71 if (info.items.isEmpty()) 73 if (info.items.isEmpty())
72 return; 74 return;
73 m_webExternalPopupMenu = 75 m_webExternalPopupMenu = m_webView.client()->createExternalPopupMenu(info, t his);
74 m_webViewClient->createExternalPopupMenu(info, this); 76 if (m_webExternalPopupMenu) {
75 if (m_webExternalPopupMenu)
76 m_webExternalPopupMenu->show(m_frameView->contentsToWindow(rect)); 77 m_webExternalPopupMenu->show(m_frameView->contentsToWindow(rect));
77 else { 78 #if OS(MACOSX)
79 const WebInputEvent* currentEvent = WebViewImpl::currentInputEvent();
80 if (currentEvent && currentEvent->type == WebInputEvent::MouseDown) {
81 m_syntheticEvent = adoptPtr(new WebMouseEvent);
82 *m_syntheticEvent = *static_cast<const WebMouseEvent*>(currentEvent) ;
83 m_syntheticEvent->type = WebInputEvent::MouseUp;
84 m_dispatchEventTimer.startOneShot(0);
85 // FIXME: show() is asynchronous. If preparing a popup is slow and
86 // a user released the mouse button before showing the popup,
87 // mouseup and click events are correctly dispatched. Dispatching
88 // the synthetic mouseup event is redundant in this case.
89 }
90 #endif
91 } else {
78 // The client might refuse to create a popup (when there is already one pending to be shown for example). 92 // The client might refuse to create a popup (when there is already one pending to be shown for example).
79 didCancel(); 93 didCancel();
80 } 94 }
81 } 95 }
82 96
97 void ExternalPopupMenu::dispatchEvent(Timer<ExternalPopupMenu>*)
98 {
99 m_webView.handleInputEvent(*m_syntheticEvent);
100 m_syntheticEvent.clear();
101 }
102
83 void ExternalPopupMenu::hide() 103 void ExternalPopupMenu::hide()
84 { 104 {
85 if (m_popupMenuClient) 105 if (m_popupMenuClient)
86 m_popupMenuClient->popupDidHide(); 106 m_popupMenuClient->popupDidHide();
87 if (!m_webExternalPopupMenu) 107 if (!m_webExternalPopupMenu)
88 return; 108 return;
89 m_webExternalPopupMenu->close(); 109 m_webExternalPopupMenu->close();
90 m_webExternalPopupMenu = 0; 110 m_webExternalPopupMenu = 0;
91 } 111 }
92 112
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 206
187 info->itemHeight = m_popupMenuClient->menuStyle().font().fontMetrics().heigh t(); 207 info->itemHeight = m_popupMenuClient->menuStyle().font().fontMetrics().heigh t();
188 info->itemFontSize = static_cast<int>(m_popupMenuClient->menuStyle().font(). size()); 208 info->itemFontSize = static_cast<int>(m_popupMenuClient->menuStyle().font(). size());
189 info->selectedIndex = m_popupMenuClient->selectedIndex(); 209 info->selectedIndex = m_popupMenuClient->selectedIndex();
190 info->rightAligned = m_popupMenuClient->menuStyle().textDirection() == WebCo re::RTL; 210 info->rightAligned = m_popupMenuClient->menuStyle().textDirection() == WebCo re::RTL;
191 info->allowMultipleSelection = m_popupMenuClient->multiple(); 211 info->allowMultipleSelection = m_popupMenuClient->multiple();
192 info->items.swap(items); 212 info->items.swap(items);
193 } 213 }
194 214
195 } 215 }
OLDNEW
« no previous file with comments | « Source/web/ExternalPopupMenu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698