Title: [191467] trunk/Source/WebKit/win
Revision
191467
Author
[email protected]
Date
2015-10-22 12:59:54 -0700 (Thu, 22 Oct 2015)

Log Message

Move menu creation to WebView
https://bugs.webkit.org/show_bug.cgi?id=150463

Reviewed by Tim Horton.

* WebView.cpp:
(createContextMenuFromItems):
(WebView::createContextMenu):

Modified Paths

Diff

Modified: trunk/Source/WebKit/win/ChangeLog (191466 => 191467)


--- trunk/Source/WebKit/win/ChangeLog	2015-10-22 19:50:09 UTC (rev 191466)
+++ trunk/Source/WebKit/win/ChangeLog	2015-10-22 19:59:54 UTC (rev 191467)
@@ -1,3 +1,14 @@
+2015-10-22  Anders Carlsson  <[email protected]>
+
+        Move menu creation to WebView
+        https://bugs.webkit.org/show_bug.cgi?id=150463
+
+        Reviewed by Tim Horton.
+
+        * WebView.cpp:
+        (createContextMenuFromItems):
+        (WebView::createContextMenu):
+
 2015-10-21  Anders Carlsson  <[email protected]>
 
         Get rid of WebContextMenuClient::customizeMenu, it's no longer used

Modified: trunk/Source/WebKit/win/WebView.cpp (191466 => 191467)


--- trunk/Source/WebKit/win/WebView.cpp	2015-10-22 19:50:09 UTC (rev 191466)
+++ trunk/Source/WebKit/win/WebView.cpp	2015-10-22 19:59:54 UTC (rev 191467)
@@ -1393,6 +1393,33 @@
     return m_page;
 }
 
+static HMENU createContextMenuFromItems(const Vector<ContextMenuItem>& items)
+{
+    HMENU menu = ::CreatePopupMenu();
+
+    for (auto& item : items) {
+        UINT flags = 0;
+
+        flags |= item.enabled() ? MF_ENABLED : MF_DISABLED;
+        flags |= item.checked() ? MF_CHECKED : MF_UNCHECKED;
+
+        switch (item.type()) {
+        case ActionType:
+        case CheckableActionType:
+            ::AppendMenu(menu, flags | MF_STRING, item.action(), item.title().charactersWithNullTermination().data());
+            break;
+        case SeparatorType:
+            ::AppendMenu(menu, flags | MF_SEPARATOR, item.action(), nullptr);
+            break;
+        case SubmenuType:
+            ::AppendMenu(menu, flags | MF_POPUP, (UINT_PTR)createContextMenuFromItems(item.subMenuItems()), item.title().charactersWithNullTermination().data());
+            break;
+        }
+    }
+
+    return menu;
+}
+
 HMENU WebView::createContextMenu()
 {
     auto& contextMenuController = m_page->contextMenuController();
@@ -1401,7 +1428,7 @@
     if (!coreMenu)
         return nullptr;
 
-    HMENU contextMenu = coreMenu->platformContextMenu();
+    HMENU contextMenu = createContextMenuFromItems(coreMenu->items());
 
     COMPtr<IWebUIDelegate> uiDelegate;
     if (SUCCEEDED(this->uiDelegate(&uiDelegate))) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to