Title: [94600] trunk/Source/WebKit/chromium
Revision
94600
Author
[email protected]
Date
2011-09-06 14:51:01 -0700 (Tue, 06 Sep 2011)

Log Message

[Chromium] Add didAcceptIndices to ExternalPopupMenuClient for Android
https://bugs.webkit.org/show_bug.cgi?id=67574

Reviewed by Darin Fisher.

In Android, external popup menus can admit multiple selection (e.g.,
for listboxes presented using external UI).

* public/WebExternalPopupMenuClient.h:
* src/ExternalPopupMenu.cpp:
(WebKit::ExternalPopupMenu::didAcceptIndices):
* src/ExternalPopupMenu.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (94599 => 94600)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-09-06 21:51:00 UTC (rev 94599)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-09-06 21:51:01 UTC (rev 94600)
@@ -1,3 +1,18 @@
+2011-09-06  Adam Barth  <[email protected]>
+
+        [Chromium] Add didAcceptIndices to ExternalPopupMenuClient for Android
+        https://bugs.webkit.org/show_bug.cgi?id=67574
+
+        Reviewed by Darin Fisher.
+
+        In Android, external popup menus can admit multiple selection (e.g.,
+        for listboxes presented using external UI).
+
+        * public/WebExternalPopupMenuClient.h:
+        * src/ExternalPopupMenu.cpp:
+        (WebKit::ExternalPopupMenu::didAcceptIndices):
+        * src/ExternalPopupMenu.h:
+
 2011-09-06  Aaron Colwell  <[email protected]>
 
         Allow MediaSource API to be enabled at runtime.

Modified: trunk/Source/WebKit/chromium/public/WebExternalPopupMenuClient.h (94599 => 94600)


--- trunk/Source/WebKit/chromium/public/WebExternalPopupMenuClient.h	2011-09-06 21:51:00 UTC (rev 94599)
+++ trunk/Source/WebKit/chromium/public/WebExternalPopupMenuClient.h	2011-09-06 21:51:01 UTC (rev 94600)
@@ -31,6 +31,8 @@
 #ifndef WebExternalPopupMenuClient_h
 #define WebExternalPopupMenuClient_h
 
+#include "WebVector.h"
+
 namespace WebKit {
 
 class WebExternalPopupMenuClient {
@@ -44,6 +46,11 @@
     // this has been called as it might not be valid anymore.
     virtual void didAcceptIndex(int index) = 0;
 
+    // Should be called when a set of indices have been selected.
+    // Note that it is not safe to access this WebExternalPopupClientMenu after
+    // this has been called as it might not be valid anymore.
+    virtual void didAcceptIndices(const WebVector<int>& indices) = 0;
+
     // Should be called when the popup menu was discarded (closed without a
     // selection.
     // Note that it is not safe to access this WebExternalPopupClientMenu after

Modified: trunk/Source/WebKit/chromium/src/ExternalPopupMenu.cpp (94599 => 94600)


--- trunk/Source/WebKit/chromium/src/ExternalPopupMenu.cpp	2011-09-06 21:51:00 UTC (rev 94599)
+++ trunk/Source/WebKit/chromium/src/ExternalPopupMenu.cpp	2011-09-06 21:51:01 UTC (rev 94600)
@@ -115,6 +115,39 @@
     m_webExternalPopupMenu = 0;
 }
 
+void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices)
+{
+#if ENABLE(NO_LISTBOX_RENDERING)
+    if (!m_popupMenuClient) {
+        m_webExternalPopupMenu = 0;
+        return
+    }
+
+    // Calling methods on the PopupMenuClient might lead to this object being
+    // derefed. This ensures it does not get deleted while we are running this
+    // method.
+    RefPtr<ExternalPopupMenu> protect(this);
+    ListPopupMenuClient* listPopupMenuClient = static_cast<ListPopupMenuClient*>(m_popupMenuClient);
+
+    if (!indices.size())
+        listPopupMenuClient->valueChanged(-1, true);
+    else {
+        for (size_t i = 0; i < indices.size(); ++i)
+            listPopupMenuClient->listBoxSelectItem(indices[i], (i > 0), false, (i == indices.size() - 1));
+    }
+
+    // The call to valueChanged above might have lead to a call to
+    // disconnectClient, so we might not have a PopupMenuClient anymore.
+    if (m_popupMenuClient)
+        m_popupMenuClient->popupDidHide();
+
+    m_webExternalPopupMenu = 0;
+
+#else
+    ASSERT_NOT_REACHED();
+#endif
+}
+
 void ExternalPopupMenu::didCancel()
 {
     // See comment in didAcceptIndex on why we need this.

Modified: trunk/Source/WebKit/chromium/src/ExternalPopupMenu.h (94599 => 94600)


--- trunk/Source/WebKit/chromium/src/ExternalPopupMenu.h	2011-09-06 21:51:00 UTC (rev 94599)
+++ trunk/Source/WebKit/chromium/src/ExternalPopupMenu.h	2011-09-06 21:51:01 UTC (rev 94600)
@@ -64,6 +64,7 @@
     // WebExternalPopupClient methods:
     virtual void didChangeSelection(int index);
     virtual void didAcceptIndex(int index);
+    virtual void didAcceptIndices(const WebVector<int>& indices);
     virtual void didCancel();
 
     // Fills |info| with the popup menu information contained in the
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to