Changeset 226602 in webkit
- Timestamp:
- Jan 8, 2018 5:53:29 PM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r226542 r226602 1 2018-01-08 Alex Christensen <achristensen@webkit.org> 2 3 Pass around Vector<Ref<WebContextMenuItem>> instead of WKArrayRef or Vector<WebContextMenuItemData> 4 https://bugs.webkit.org/show_bug.cgi?id=181419 5 6 Reviewed by Tim Horton. 7 8 Passing a WKArrayRef to an API object is messy and was preventing me from moving things around and making ObjC SPI. 9 No change in behavior. Just using different layering abstractions for the same data. 10 11 * UIProcess/API/C/WKContextMenuListener.cpp: 12 (WKContextMenuListenerUseContextMenuItems): 13 * UIProcess/WebContextMenuListenerProxy.cpp: 14 (WebKit::WebContextMenuListenerProxy::useContextMenuItems): 15 * UIProcess/WebContextMenuListenerProxy.h: 16 * UIProcess/WebContextMenuProxy.h: 17 * UIProcess/mac/WebContextMenuProxyMac.h: 18 * UIProcess/mac/WebContextMenuProxyMac.mm: 19 (WebKit::WebContextMenuProxyMac::showContextMenuWithItems): 20 (WebKit::WebContextMenuProxyMac::showContextMenu): 21 1 22 2018-01-08 John Wilander <wilander@apple.com> 2 23 -
trunk/Source/WebKit/UIProcess/API/C/WKContextMenuListener.cpp
r207558 r226602 27 27 #include "WKContextMenuListener.h" 28 28 29 #include "APIArray.h" 29 30 #include "WKAPICast.h" 31 #include "WebContextMenuItem.h" 30 32 #include "WebContextMenuListenerProxy.h" 31 33 … … 41 43 } 42 44 43 void WKContextMenuListenerUseContextMenuItems(WKContextMenuListenerRef listenerRef, WKArrayRef items)45 void WKContextMenuListenerUseContextMenuItems(WKContextMenuListenerRef listenerRef, WKArrayRef arrayRef) 44 46 { 45 47 #if ENABLE(CONTEXT_MENUS) 46 toImpl(listenerRef)->useContextMenuItems(items); 48 RefPtr<API::Array> array = toImpl(arrayRef); 49 size_t newSize = array ? array->size() : 0; 50 Vector<Ref<WebContextMenuItem>> items; 51 items.reserveInitialCapacity(newSize); 52 for (size_t i = 0; i < newSize; ++i) { 53 WebContextMenuItem* item = array->at<WebContextMenuItem>(i); 54 if (!item) 55 continue; 56 57 items.uncheckedAppend(*item); 58 } 59 60 toImpl(listenerRef)->useContextMenuItems(WTFMove(items)); 47 61 #else 48 62 UNUSED_PARAM(listenerRef); -
trunk/Source/WebKit/UIProcess/WebContextMenuListenerProxy.cpp
r226323 r226602 48 48 } 49 49 50 void WebContextMenuListenerProxy::useContextMenuItems( WKArrayRefitems)50 void WebContextMenuListenerProxy::useContextMenuItems(Vector<Ref<WebContextMenuItem>>&& items) 51 51 { 52 52 if (!m_contextMenuMac) 53 53 return; 54 54 55 RefPtr<API::Array> array = toImpl(items); 56 size_t newSize = array ? array->size() : 0; 57 Vector<WebContextMenuItemData> dataItems; 58 dataItems.reserveInitialCapacity(newSize); 59 for (size_t i = 0; i < newSize; ++i) { 60 WebContextMenuItem* item = array->at<WebContextMenuItem>(i); 61 if (!item) 62 continue; 63 64 dataItems.uncheckedAppend(item->data()); 65 } 66 67 m_contextMenuMac->showContextMenuWithItems(WTFMove(dataItems)); 55 m_contextMenuMac->showContextMenuWithItems(WTFMove(items)); 68 56 } 69 57 -
trunk/Source/WebKit/UIProcess/WebContextMenuListenerProxy.h
r216794 r226602 45 45 virtual ~WebContextMenuListenerProxy(); 46 46 47 void useContextMenuItems( WKArrayRef items);47 void useContextMenuItems(Vector<Ref<WebContextMenuItem>>&&); 48 48 49 49 void invalidate(); -
trunk/Source/WebKit/UIProcess/WebContextMenuProxy.h
r226323 r226602 42 42 virtual void show() = 0; 43 43 44 virtual void showContextMenuWithItems( Vector<WebContextMenuItemData>&&) = 0;44 virtual void showContextMenuWithItems(const Vector<Ref<WebContextMenuItem>>&) = 0; 45 45 46 46 protected: -
trunk/Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.cpp
r226323 r226602 176 176 } 177 177 178 void WebContextMenuProxyGtk::showContextMenuWithItems( Vector<WebContextMenuItemData>&&)178 void WebContextMenuProxyGtk::showContextMenuWithItems(const Vector<Ref<WebContextMenuItem>>&) 179 179 { 180 180 } -
trunk/Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.h
r226323 r226602 56 56 WebContextMenuProxyGtk(GtkWidget*, WebPageProxy&, ContextMenuContextData&&, const UserData&); 57 57 void show() override; 58 void showContextMenuWithItems( Vector<WebContextMenuItemData>&&) override;58 void showContextMenuWithItems(const Vector<Ref<WebContextMenuItem>>&) override; 59 59 void append(GMenu*, const WebContextMenuItemGlib&); 60 60 GRefPtr<GMenu> buildMenu(const Vector<WebContextMenuItemGlib>&); -
trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h
r226323 r226602 55 55 56 56 void contextMenuItemSelected(const WebContextMenuItemData&); 57 void showContextMenuWithItems( Vector<WebContextMenuItemData>&&) override;57 void showContextMenuWithItems(const Vector<Ref<WebContextMenuItem>>&) override; 58 58 59 59 #if ENABLE(SERVICE_CONTROLS) -
trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm
r226323 r226602 452 452 } 453 453 454 void WebContextMenuProxyMac::showContextMenuWithItems(Vector<WebContextMenuItemData>&& items) 455 { 456 auto menu = createContextMenuFromItems(items); 454 void WebContextMenuProxyMac::showContextMenuWithItems(const Vector<Ref<WebContextMenuItem>>& items) 455 { 456 Vector<WebContextMenuItemData> data; 457 data.reserveInitialCapacity(items.size()); 458 for (auto& item : items) 459 data.uncheckedAppend(item->data()); 460 461 auto menu = createContextMenuFromItems(data); 457 462 [[WKMenuTarget sharedMenuTarget] setMenuProxy:this]; 458 463 m_menu = m_page.contextMenuClient().menuFromProposedMenu(m_page, menu.get(), m_context.webHitTestResultData(), m_userData.object()); … … 494 499 return; 495 500 496 Vector<WebContextMenuItemData> items; 497 for (auto& item : (useProposedItems ? proposedAPIItems : clientItems)) 498 items.append(item->data()); 499 501 auto&& items = WTFMove(useProposedItems ? proposedAPIItems : clientItems); 502 500 503 if (items.isEmpty()) 501 504 return; 502 505 503 showContextMenuWithItems( WTFMove(items));506 showContextMenuWithItems(items); 504 507 } 505 508 -
trunk/Source/WebKit/UIProcess/wpe/WebContextMenuProxyWPE.h
r226323 r226602 37 37 } 38 38 39 void showContextMenuWithItems( Vector<WebContextMenuItemData>&&) final { }39 void showContextMenuWithItems(const Vector<Ref<WebContextMenuItem>>&) final { } 40 40 void show() final { }; 41 41
Note: See TracChangeset
for help on using the changeset viewer.