Changeset 271206 in webkit
- Timestamp:
- Jan 6, 2021, 11:31:01 AM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (modified) (2 diffs)
-
WebProcess/WebCoreSupport/WebContextMenuClient.cpp (modified) (1 diff)
-
WebProcess/WebPage/WebContextMenu.cpp (modified) (1 diff)
-
WebProcess/WebPage/WebContextMenu.h (modified) (5 diffs)
-
WebProcess/WebPage/WebPage.cpp (modified) (4 diffs)
-
WebProcess/WebPage/WebPage.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r271205 r271206 1 2021-01-06 Alex Christensen <achristensen@webkit.org> 2 3 Modernize WebContextMenu 4 https://bugs.webkit.org/show_bug.cgi?id=219969 5 6 Reviewed by Tim Horton. 7 8 This is old code, complete with a raw pointer. 9 Use references instead of pointers where possible, 10 and WeakPtr instead of a raw pointer. 11 12 * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: 13 (WKBundlePageClickMenuItem): 14 (WKBundlePageCopyContextMenuItems): 15 * WebProcess/WebCoreSupport/WebContextMenuClient.cpp: 16 (WebKit::WebContextMenuClient::showContextMenu): 17 * WebProcess/WebPage/WebContextMenu.cpp: 18 (WebKit::WebContextMenu::WebContextMenu): 19 * WebProcess/WebPage/WebContextMenu.h: 20 (WebKit::WebContextMenu::create): 21 * WebProcess/WebPage/WebPage.cpp: 22 (WebKit::WebPage::contextMenu): 23 (WebKit::WebPage::contextMenuAtPointInWindow): 24 (WebKit::handleContextMenuEvent): 25 (WebKit::WebPage::contextMenuForKeyEvent): 26 1 27 2021-01-06 Sihui Liu <sihui_liu@appe.com> 2 28 -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
r270647 r271206 182 182 { 183 183 #if ENABLE(CONTEXT_MENUS) 184 WebKit::toImpl(pageRef)->contextMenu() ->itemSelected(WebKit::toImpl(item)->data());184 WebKit::toImpl(pageRef)->contextMenu().itemSelected(WebKit::toImpl(item)->data()); 185 185 #else 186 186 UNUSED_PARAM(pageRef); … … 207 207 { 208 208 #if ENABLE(CONTEXT_MENUS) 209 WebKit::WebContextMenu*contextMenu = WebKit::toImpl(pageRef)->contextMenu();210 211 return WebKit::toAPI(&contextMenuItems( *contextMenu).leakRef());209 auto& contextMenu = WebKit::toImpl(pageRef)->contextMenu(); 210 211 return WebKit::toAPI(&contextMenuItems(contextMenu).leakRef()); 212 212 #else 213 213 UNUSED_PARAM(pageRef); -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.cpp
r271124 r271206 96 96 void WebContextMenuClient::showContextMenu() 97 97 { 98 m_page->contextMenu() ->show();98 m_page->contextMenu().show(); 99 99 } 100 100 -
trunk/Source/WebKit/WebProcess/WebPage/WebContextMenu.cpp
r255106 r271206 41 41 using namespace WebCore; 42 42 43 WebContextMenu::WebContextMenu(WebPage *page)44 : m_page( page)43 WebContextMenu::WebContextMenu(WebPage& page) 44 : m_page(makeWeakPtr(page)) 45 45 { 46 46 } -
trunk/Source/WebKit/WebProcess/WebPage/WebContextMenu.h
r204466 r271206 19 19 */ 20 20 21 #ifndef WebContextMenu_h 22 #define WebContextMenu_h 21 #pragma once 23 22 24 23 #if ENABLE(CONTEXT_MENUS) … … 28 27 #include <wtf/RefCounted.h> 29 28 #include <wtf/RefPtr.h> 29 #include <wtf/WeakPtr.h> 30 30 31 31 namespace WebCore { … … 40 40 class WebContextMenu : public RefCounted<WebContextMenu> { 41 41 public: 42 static Ref<WebContextMenu> create(WebPage * page)42 static Ref<WebContextMenu> create(WebPage& page) 43 43 { 44 44 return adoptRef(*new WebContextMenu(page)); … … 52 52 53 53 private: 54 WebContextMenu(WebPage *);54 WebContextMenu(WebPage&); 55 55 void menuItemsWithUserData(Vector<WebContextMenuItemData>&, RefPtr<API::Object>&) const; 56 56 57 We bPage*m_page;57 WeakPtr<WebPage> m_page; 58 58 }; 59 59 … … 61 61 62 62 #endif // ENABLE(CONTEXT_MENUS) 63 #endif // WebPopupMenu_h -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r271194 r271206 2588 2588 2589 2589 #if ENABLE(CONTEXT_MENUS) 2590 WebContextMenu *WebPage::contextMenu()2590 WebContextMenu& WebPage::contextMenu() 2591 2591 { 2592 2592 if (!m_contextMenu) 2593 m_contextMenu = WebContextMenu::create( this);2594 return m_contextMenu.get();2593 m_contextMenu = WebContextMenu::create(*this); 2594 return *m_contextMenu; 2595 2595 } 2596 2596 … … 2603 2603 corePage()->userInputBridge().handleMousePressEvent(mousePressEvent); 2604 2604 bool handled = corePage()->userInputBridge().handleContextMenuEvent(mousePressEvent, corePage()->mainFrame()); 2605 auto* menu = handled ? contextMenu() : nullptr;2605 auto* menu = handled ? &contextMenu() : nullptr; 2606 2606 PlatformMouseEvent mouseReleaseEvent(point, point, RightButton, PlatformEvent::MouseReleased, 1, false, false, false, false, WallTime::now(), WebCore::ForceAtClick, WebCore::NoTap); 2607 2607 corePage()->userInputBridge().handleMouseReleaseEvent(mouseReleaseEvent); … … 2751 2751 #if ENABLE(CONTEXT_MENUS) 2752 2752 if (handled) 2753 page->contextMenu() ->show();2753 page->contextMenu().show(); 2754 2754 #endif 2755 2755 return handled; … … 2766 2766 #if ENABLE(CONTEXT_MENUS) 2767 2767 if (handled) 2768 contextMenu() ->show();2768 contextMenu().show(); 2769 2769 #else 2770 2770 UNUSED_PARAM(handled); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r271201 r271206 820 820 821 821 #if ENABLE(CONTEXT_MENUS) 822 WebContextMenu *contextMenu();822 WebContextMenu& contextMenu(); 823 823 WebContextMenu* contextMenuAtPointInWindow(const WebCore::IntPoint&); 824 824 #endif
Note:
See TracChangeset
for help on using the changeset viewer.