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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/ExternalPopupMenu.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/ExternalPopupMenu.cpp
diff --git a/Source/web/ExternalPopupMenu.cpp b/Source/web/ExternalPopupMenu.cpp
index 38c08959221205bd8c9aa693537a0c5ac956612c..427246107d49d6057b085eda67870ed0dfb39dae 100644
--- a/Source/web/ExternalPopupMenu.cpp
+++ b/Source/web/ExternalPopupMenu.cpp
@@ -35,6 +35,7 @@
#include "WebMenuItemInfo.h"
#include "WebPopupMenuInfo.h"
#include "WebViewClient.h"
+#include "WebViewImpl.h"
#include "core/frame/Frame.h"
#include "core/frame/FrameView.h"
#include "platform/PopupMenuClient.h"
@@ -47,10 +48,11 @@ using namespace WebCore;
namespace blink {
-ExternalPopupMenu::ExternalPopupMenu(Frame& frame, PopupMenuClient* popupMenuClient, WebViewClient* webViewClient)
+ExternalPopupMenu::ExternalPopupMenu(Frame& frame, PopupMenuClient* popupMenuClient, WebViewImpl& webView)
: m_popupMenuClient(popupMenuClient)
, m_frameView(frame.view())
- , m_webViewClient(webViewClient)
+ , m_webView(webView)
+ , m_dispatchEventTimer(this, &ExternalPopupMenu::dispatchEvent)
, m_webExternalPopupMenu(0)
{
}
@@ -70,16 +72,34 @@ void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, i
getPopupMenuInfo(&info);
if (info.items.isEmpty())
return;
- m_webExternalPopupMenu =
- m_webViewClient->createExternalPopupMenu(info, this);
- if (m_webExternalPopupMenu)
+ m_webExternalPopupMenu = m_webView.client()->createExternalPopupMenu(info, this);
+ if (m_webExternalPopupMenu) {
m_webExternalPopupMenu->show(m_frameView->contentsToWindow(rect));
- else {
+#if OS(MACOSX)
+ const WebInputEvent* currentEvent = WebViewImpl::currentInputEvent();
+ if (currentEvent && currentEvent->type == WebInputEvent::MouseDown) {
+ m_syntheticEvent = adoptPtr(new WebMouseEvent);
+ *m_syntheticEvent = *static_cast<const WebMouseEvent*>(currentEvent);
+ m_syntheticEvent->type = WebInputEvent::MouseUp;
+ m_dispatchEventTimer.startOneShot(0);
+ // FIXME: show() is asynchronous. If preparing a popup is slow and
+ // a user released the mouse button before showing the popup,
+ // mouseup and click events are correctly dispatched. Dispatching
+ // the synthetic mouseup event is redundant in this case.
+ }
+#endif
+ } else {
// The client might refuse to create a popup (when there is already one pending to be shown for example).
didCancel();
}
}
+void ExternalPopupMenu::dispatchEvent(Timer<ExternalPopupMenu>*)
+{
+ m_webView.handleInputEvent(*m_syntheticEvent);
+ m_syntheticEvent.clear();
+}
+
void ExternalPopupMenu::hide()
{
if (m_popupMenuClient)
« 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