Changeset 270606 in webkit
- Timestamp:
- Dec 9, 2020, 3:08:25 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 24 edited
- 4 copied
-
WebInspectorUI/ChangeLog (modified) (1 diff)
-
WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js (modified) (3 diffs)
-
WebInspectorUI/UserInterface/Main.html (modified) (2 diffs)
-
WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js (modified) (1 diff)
-
WebInspectorUI/UserInterface/Views/GeneralTabBarItem.js (modified) (1 diff)
-
WebInspectorUI/UserInterface/Views/PinnedTabBarItem.js (modified) (1 diff)
-
WebInspectorUI/UserInterface/Views/TabContentView.js (modified) (3 diffs)
-
WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.css (copied) (copied from trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h ) (2 diffs)
-
WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.js (copied) (copied from trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.h ) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/Platform/Logging.h (modified) (1 diff)
-
WebKit/Shared/InspectorExtensionTypes.h (modified) (1 diff)
-
WebKit/Sources.txt (modified) (1 diff)
-
WebKit/UIProcess/API/APIInspectorExtension.cpp (copied) (copied from trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.h ) (1 diff)
-
WebKit/UIProcess/API/APIInspectorExtension.h (modified) (2 diffs)
-
WebKit/UIProcess/API/Cocoa/_WKInspector.mm (modified) (1 diff)
-
WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h (modified) (3 diffs)
-
WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.mm (modified) (3 diffs)
-
WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionInternal.h (modified) (2 diffs)
-
WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm (modified) (3 diffs)
-
WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerInternal.h (copied) (copied from trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h ) (1 diff)
-
WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp (modified) (1 diff)
-
WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h (modified) (1 diff)
-
WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h (modified) (1 diff)
-
WebKit/WebKit.xcodeproj/project.pbxproj (modified) (2 diffs)
-
WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp (modified) (2 diffs)
-
WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h (modified) (1 diff)
-
WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.messages.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r270604 r270606 1 2020-11-30 Brian Burg <bburg@apple.com> 2 3 [Cocoa] Web Inspector: add support for creating extension tabs in WebInspectorUI via _WKInspectorExtension 4 https://bugs.webkit.org/show_bug.cgi?id=219380 5 6 Reviewed by Devin Rousso and Timothy Hatcher. 7 8 * UserInterface/Controllers/WebInspectorExtensionController.js: 9 (WI.WebInspectorExtensionController): 10 (WI.WebInspectorExtensionController.prototype._makeNextExtensionTabID): 11 (WI.WebInspectorExtensionController.prototype.unregisterExtension): 12 (WI.WebInspectorExtensionController.prototype.createTabForExtension): 13 * UserInterface/Main.html: 14 * UserInterface/Protocol/InspectorFrontendAPI.js: 15 (InspectorFrontendAPI.createTabForExtension): 16 * UserInterface/Views/GeneralTabBarItem.js: 17 (WI.GeneralTabBarItem.fromTabContentView): 18 (WI.GeneralTabBarItem.get displayName): Deleted. 19 * UserInterface/Views/PinnedTabBarItem.js: 20 (WI.PinnedTabBarItem.fromTabContentView): 21 (WI.PinnedTabBarItem): 22 * UserInterface/Views/TabContentView.js: 23 (WI.TabContentView.prototype.get tabBarItem): 24 (WI.TabContentView.prototype.tabInfo): 25 (WI.TabContentView.prototype.get managesNavigationSidebarPanel): Deleted. 26 (WI.TabContentView.prototype.attached): Deleted. 27 * UserInterface/Views/WebInspectorExtensionTabContentView.css: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h. 28 (.content-view.web-inspector-extension-tab > iframe): 29 * UserInterface/Views/WebInspectorExtensionTabContentView.js: Copied from Source/WebKit/UIProcess/API/APIInspectorExtension.h. 30 (WI.WebInspectorExtensionTabContentView): 31 (WI.WebInspectorExtensionTabContentView.prototype.tabInfo): 32 (WI.WebInspectorExtensionTabContentView.prototype.get type): 33 (WI.WebInspectorExtensionTabContentView.prototype.get supportsSplitContentBrowser): 34 (WI.WebInspectorExtensionTabContentView.prototype.get extensionTabID): 35 (WI.WebInspectorExtensionTabContentView.prototype.initialLayout): 36 1 37 2020-12-09 Devin Rousso <drousso@apple.com> 2 38 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js
r269701 r270606 30 30 super(); 31 31 32 this._extensionIDMap = new Map; 32 this._extensionForExtensionIDMap = new Map; 33 this._extensionTabContentViewForExtensionTabIDMap = new Map; 34 this._tabIDsForExtensionIDMap = new Multimap; 35 this._nextExtensionTabID = 1; 33 36 } 34 37 … … 37 40 registerExtension(extensionID, displayName) 38 41 { 39 if (this._extension IDMap.has(extensionID)) {40 WI.reportInternalError("Unable to register extension, it's already registered: " , extensionID, displayName);42 if (this._extensionForExtensionIDMap.has(extensionID)) { 43 WI.reportInternalError("Unable to register extension, it's already registered: " + extensionID); 41 44 return WI.WebInspectorExtension.ErrorCode.RegistrationFailed; 42 45 } 43 46 44 47 let extension = new WI.WebInspectorExtension(extensionID, displayName); 45 this._extension IDMap.set(extensionID, extension);48 this._extensionForExtensionIDMap.set(extensionID, extension); 46 49 47 50 this.dispatchEventToListeners(WI.WebInspectorExtensionController.Event.ExtensionAdded, {extension}); … … 50 53 unregisterExtension(extensionID) 51 54 { 52 let extension = this._extension IDMap.take(extensionID);55 let extension = this._extensionForExtensionIDMap.take(extensionID); 53 56 if (!extension) { 54 WI.reportInternalError("Unable to unregister extension with unknown ID: " ,extensionID);57 WI.reportInternalError("Unable to unregister extension with unknown ID: " + extensionID); 55 58 return WI.WebInspectorExtension.ErrorCode.InvalidRequest; 56 59 } 57 60 61 let extensionTabIDsToRemove = this._tabIDsForExtensionIDMap.take(extensionID) || []; 62 for (let extensionTabID of extensionTabIDsToRemove) { 63 let tabContentView = this._extensionTabContentViewForExtensionTabIDMap.take(extensionTabID); 64 WI.tabBrowser.closeTabForContentView(tabContentView); 65 } 66 58 67 this.dispatchEventToListeners(WI.WebInspectorExtensionController.Event.ExtensionRemoved, {extension}); 68 } 69 70 createTabForExtension(extensionID, tabName, tabIconURL, sourceURL) 71 { 72 let extension = this._extensionForExtensionIDMap.get(extensionID); 73 if (!extension) { 74 WI.reportInternalError("Unable to create tab for extension with unknown ID: " + extensionID + " sourceURL: " + sourceURL); 75 return WI.WebInspectorExtension.ErrorCode.InvalidRequest; 76 } 77 78 let extensionTabID = `WebExtensionTab-${extensionID}-${this._nextExtensionTabID++}`; 79 let tabContentView = new WI.WebInspectorExtensionTabContentView(extension, extensionTabID, tabName, tabIconURL, sourceURL); 80 81 this._tabIDsForExtensionIDMap.add(extensionID, extensionTabID); 82 this._extensionTabContentViewForExtensionTabIDMap.set(extensionTabID, tabContentView); 83 WI.tabBrowser.addTabForContentView(tabContentView); 84 85 // The calling convention is to return an error string or a result object. 86 return {extensionTabID}; 59 87 } 60 88 }; -
trunk/Source/WebInspectorUI/UserInterface/Main.html
r270604 r270606 248 248 <link rel="stylesheet" href="Views/URLBreakpointTreeElement.css"> 249 249 <link rel="stylesheet" href="Views/Variables.css"> 250 <link rel="stylesheet" href="Views/WebInspectorExtensionTabContentView.css"> 250 251 <link rel="stylesheet" href="Views/WebSocketContentView.css"> 251 252 … … 584 585 <script src="Views/StorageTabContentView.js"></script> 585 586 <script src="Views/TimelineTabContentView.js"></script> 587 <script src="Views/WebInspectorExtensionTabContentView.js"></script> 586 588 587 589 <script src="Views/DetailsSection.js"></script> -
trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js
r269701 r270606 210 210 return WI.sharedApp.extensionController.unregisterExtension(extensionID); 211 211 }, 212 213 // Returns a WI.WebInspectorExtension.ErrorCode if an error occurred, otherwise an object 214 // with an 'inspectorExtensionID' key representing the tab identifier for the newly created tab. 215 createTabForExtension(extensionID, tabName, tabIconURL, sourceURL) 216 { 217 return WI.sharedApp.extensionController.createTabForExtension(extensionID, tabName, tabIconURL, sourceURL); 218 }, 212 219 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/GeneralTabBarItem.js
r259101 r270606 33 33 console.assert(tabContentView instanceof WI.TabContentView); 34 34 35 let {image, displayName, title} = tabContentView. constructor.tabInfo();35 let {image, displayName, title} = tabContentView.tabInfo(); 36 36 return new WI.GeneralTabBarItem(tabContentView, image, displayName, title); 37 37 } -
trunk/Source/WebInspectorUI/UserInterface/Views/PinnedTabBarItem.js
r259101 r270606 39 39 console.assert(tabContentView instanceof WI.TabContentView); 40 40 41 let {image, displayName, title} = tabContentView. constructor.tabInfo();41 let {image, displayName, title} = tabContentView.tabInfo(); 42 42 return new WI.PinnedTabBarItem(tabContentView, image, displayName, title); 43 43 } -
trunk/Source/WebInspectorUI/UserInterface/Views/TabContentView.js
r270134 r270606 34 34 35 35 this._identifier = tabInfo.identifier; 36 this._tabBarItem = this.constructor.shouldPinTab() ? WI.PinnedTabBarItem.fromTabContentView(this) : WI.GeneralTabBarItem.fromTabContentView(this);37 36 this._navigationSidebarPanelConstructor = navigationSidebarPanelConstructor || null; 38 37 this._detailsSidebarPanelConstructors = detailsSidebarPanelConstructors || []; … … 83 82 get tabBarItem() 84 83 { 84 // This is created lazily to break a dependency cycle for dynamically-created TabContentViews. 85 // TabContentViews with a non-static tabInfo() must be fully constructed before calling tabInfo(). 86 if (!this._tabBarItem) 87 this._tabBarItem = this.constructor.shouldPinTab() ? WI.PinnedTabBarItem.fromTabContentView(this) : WI.GeneralTabBarItem.fromTabContentView(this); 88 85 89 return this._tabBarItem; 86 90 } … … 124 128 // Can be overridden by subclasses. 125 129 return false; 130 } 131 132 tabInfo() 133 { 134 // Can be overridden by subclasses. 135 return this.constructor.tabInfo(); 126 136 } 127 137 -
trunk/Source/WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.css
r270605 r270606 1 1 /* 2 * Copyright (C) 2020 Apple Inc. All rights reserved.2 * Copyright (C) 2020 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #import <Foundation/Foundation.h> 27 #import <WebKit/WKFoundation.h> 26 .content-view.tab.web-inspector-extension > iframe { 27 border: 0; 28 28 29 NS_ASSUME_NONNULL_BEGIN 29 position: absolute; 30 top: 0; 31 left: 0; 32 right: 0; 33 bottom: 0; 30 34 31 WK_CLASS_AVAILABLE(macos(WK_MAC_TBA)) 32 @interface _WKInspectorExtension : NSObject 33 34 - (instancetype)init NS_UNAVAILABLE; 35 36 @property (readonly, nonatomic) NSString *extensionID; 37 38 @end 39 40 NS_ASSUME_NONNULL_END 35 /* This is required for the iframe to expand if its intrinsic size */ 36 /* is smaller than the tab content view. */ 37 width: 100%; 38 height: 100%; 39 } -
trunk/Source/WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.js
r270605 r270606 24 24 */ 25 25 26 #pragma once 26 WI.WebInspectorExtensionTabContentView = class WebInspectorExtensionTabContentView extends WI.TabContentView 27 { 28 constructor(extension, extensionTabID, tabLabel, iconURL, sourceURL) 29 { 30 let tabInfo = { 31 identifier: WI.WebInspectorExtensionTabContentView.Type, 32 image: iconURL, 33 displayName: tabLabel, 34 title: tabLabel, 35 }; 36 super(tabInfo); 27 37 28 #if ENABLE(INSPECTOR_EXTENSIONS) 29 30 #include "APIObject.h" 31 #include <wtf/Forward.h> 32 33 namespace API { 34 35 class InspectorExtension final : public API::ObjectImpl<Object::Type::InspectorExtension> { 36 public: 37 static Ref<InspectorExtension> create(const WTF::String& identifier) 38 { 39 return adoptRef(*new InspectorExtension(identifier)); 38 this._extension = extension; 39 this._extensionTabID = extensionTabID; 40 this._tabInfo = tabInfo; 41 this._sourceURL = sourceURL; 40 42 } 41 43 42 explicit InspectorExtension(const WTF::String& identifier) 43 : m_identifier(identifier) 44 // Public 45 46 get extensionTabID() { return this._extensionTabID; } 47 48 get type() 44 49 { 50 return WI.WebInspectorExtensionTabContentView.Type; 45 51 } 46 52 47 const WTF::String& identifier() const { return m_identifier; } 53 get supportsSplitContentBrowser() 54 { 55 return true; 56 } 48 57 49 private: 50 WTF::String m_identifier; 58 tabInfo() 59 { 60 return this._tabInfo; 61 } 62 63 static shouldSaveTab() { return false; } 64 65 // Protected 66 67 initialLayout() 68 { 69 super.initialLayout(); 70 71 let iframeElement = this.element.appendChild(document.createElement("iframe")); 72 iframeElement.src = this._sourceURL; 73 } 51 74 }; 52 75 53 } // namespace API 54 55 #endif // ENABLE(INSPECTOR_EXTENSIONS) 76 WI.WebInspectorExtensionTabContentView.Type = "web-inspector-extension"; -
trunk/Source/WebKit/ChangeLog
r270605 r270606 1 2020-11-30 Brian Burg <bburg@apple.com> 2 3 [Cocoa] Web Inspector: add support for creating extension tabs in WebInspectorUI via _WKInspectorExtension 4 https://bugs.webkit.org/show_bug.cgi?id=219380 5 6 Reviewed by Devin Rousso and Timothy Hatcher. 7 8 Add a new method to _WKInspectorExtension for creating an extension tab in WebInpectorUI. 9 This can be used to implement browser.devtools.panels.create() as provided by the Web Extensions API. 10 11 * Platform/Logging.h: Add Inspector channel for error logging. 12 * Shared/InspectorExtensionTypes.h: Add a missing EnumTraits case. 13 * WebKit.xcodeproj/project.pbxproj: 14 * Sources.txt: Add files. 15 16 * UIProcess/API/APIInspectorExtension.h: 17 * UIProcess/API/APIInspectorExtension.cpp: 18 (API::InspectorExtension::InspectorExtension): 19 (API::InspectorExtension::create): 20 (API::InspectorExtension::createTab): 21 Inspector extensions need to be able to invoke commands in the WebProcess-side 22 extension proxy controller, so keep a WeakRef to the extension controller that 23 created the extension object. Also, implement the new API by forwarding it on. 24 25 * UIProcess/API/Cocoa/_WKInspector.mm: 26 (-[_WKInspector registerExtensionWithID:displayName:completionHandler:]): 27 Adapt to the new constructor as explained above. 28 29 * UIProcess/API/Cocoa/_WKInspectorExtensionInternal.h: 30 Expose member m_remoteInspectorPorxy for use in the API::InspectorExtension constructor. 31 32 * UIProcess/API/Cocoa/_WKInspectorExtension.h: 33 * UIProcess/API/Cocoa/_WKInspectorExtension.mm: 34 (-[_WKInspectorExtension initWithIdentifier:]): Deleted. 35 36 (-[_WKInspectorExtension createTabWithName:tabIconURL:sourceURL:completionHandler:]): 37 Implement new API. 38 39 * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerInternal.h: Added. 40 Make the RefPtr<RemoteWebInspectorProxy> member variable accessible to the API object constructor. 41 42 * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm: 43 (-[_WKRemoteWebInspectorViewController registerExtensionWithID:displayName:completionHandler:]): 44 Adapt to new constructor as explained above. 45 46 * UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h: 47 * UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp: 48 (WebKit::WebInspectorUIExtensionControllerProxy::createTabForExtension): 49 Forward the request to the inspector frontend WebProcess. 50 51 * WebProcess/Inspector/WebInspectorUIExtensionController.messages.in: 52 Add a new async IPC command for creating a new inspector extension tab. 53 54 * WebProcess/Inspector/WebInspectorUIExtensionController.h: 55 * WebProcess/Inspector/WebInspectorUIExtensionController.cpp: 56 (WebKit::WebInspectorUIExtensionController::unwrapEvaluationResultAsObject): 57 Added. Pull out the code needed for error-handling this common operation. 58 59 (WebKit::WebInspectorUIExtensionController::createTabForExtension): 60 Added. Call into InspectorFrontendAPI to request a new tab. Turn the result 61 into an InspectorExtensionError or InspectorExtensionTabID and send the IPC reply. 62 63 * UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h: 64 Fix unified sources fallout. 65 1 66 2020-12-09 Said Abou-Hallawa <said@apple.com> 2 67 -
trunk/Source/WebKit/Platform/Logging.h
r270453 r270606 61 61 M(IncrementalPDF) \ 62 62 M(IncrementalPDFVerbose) \ 63 M(IndexedDB) \ 63 64 M(Inspector) \ 64 M(IndexedDB) \65 65 M(KeyHandling) \ 66 66 M(Layers) \ -
trunk/Source/WebKit/Shared/InspectorExtensionTypes.h
r269701 r270606 51 51 using values = EnumValues< 52 52 WebKit::InspectorExtensionError, 53 WebKit::InspectorExtensionError::ContextDestroyed, 54 WebKit::InspectorExtensionError::InternalError, 53 55 WebKit::InspectorExtensionError::InvalidRequest, 54 WebKit::InspectorExtensionError::ContextDestroyed,55 56 WebKit::InspectorExtensionError::RegistrationFailed 56 57 >; -
trunk/Source/WebKit/Sources.txt
r270587 r270606 354 354 UIProcess/API/APIHitTestResult.cpp 355 355 UIProcess/API/APIInspectorConfiguration.cpp 356 UIProcess/API/APIInspectorExtension.cpp 356 357 UIProcess/API/APIInternalDebugFeature.cpp 357 358 UIProcess/API/APINavigation.cpp -
trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.cpp
r270605 r270606 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "APIInspectorExtension.h" 27 28 28 29 #if ENABLE(INSPECTOR_EXTENSIONS) 29 30 30 #include " APIObject.h"31 #include <wtf/Forward.h>31 #include "InspectorExtensionTypes.h" 32 #include "WebInspectorUIExtensionControllerProxy.h" 32 33 33 34 namespace API { 34 35 35 class InspectorExtension final : public API::ObjectImpl<Object::Type::InspectorExtension> { 36 public: 37 static Ref<InspectorExtension> create(const WTF::String& identifier) 38 { 39 return adoptRef(*new InspectorExtension(identifier)); 36 InspectorExtension::InspectorExtension(const WTF::String& identifier, WebKit::WebInspectorUIExtensionControllerProxy& extensionControllerProxy) 37 : m_identifier(identifier) 38 , m_extensionControllerProxy(makeWeakPtr(extensionControllerProxy)) 39 { 40 } 41 42 Ref<InspectorExtension> InspectorExtension::create(const WTF::String& identifier, WebKit::WebInspectorUIExtensionControllerProxy& extensionControllerProxy) 43 { 44 return adoptRef(*new InspectorExtension(identifier, extensionControllerProxy)); 45 } 46 47 void InspectorExtension::createTab(const WTF::String& tabName, const WTF::URL& tabIconURL, const WTF::URL& sourceURL, WTF::CompletionHandler<void(Expected<WebKit::InspectorExtensionTabID, WebKit::InspectorExtensionError>)>&& completionHandler) 48 { 49 if (!m_extensionControllerProxy) { 50 completionHandler(makeUnexpected(WebKit::InspectorExtensionError::ContextDestroyed)); 51 return; 40 52 } 41 53 42 explicit InspectorExtension(const WTF::String& identifier) 43 : m_identifier(identifier) 44 { 45 } 46 47 const WTF::String& identifier() const { return m_identifier; } 48 49 private: 50 WTF::String m_identifier; 51 }; 54 m_extensionControllerProxy->createTabForExtension(m_identifier, tabName, tabIconURL, sourceURL, WTFMove(completionHandler)); 55 } 52 56 53 57 } // namespace API -
trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.h
r269701 r270606 29 29 30 30 #include "APIObject.h" 31 #include "InspectorExtensionTypes.h" 32 #include <wtf/CompletionHandler.h> 31 33 #include <wtf/Forward.h> 34 #include <wtf/WeakPtr.h> 35 #include <wtf/text/WTFString.h> 36 37 namespace WebKit { 38 class WebInspectorUIExtensionControllerProxy; 39 } 32 40 33 41 namespace API { … … 35 43 class InspectorExtension final : public API::ObjectImpl<Object::Type::InspectorExtension> { 36 44 public: 37 static Ref<InspectorExtension> create(const WTF::String& identifier) 38 { 39 return adoptRef(*new InspectorExtension(identifier)); 40 } 41 42 explicit InspectorExtension(const WTF::String& identifier) 43 : m_identifier(identifier) 44 { 45 } 45 static Ref<InspectorExtension> create(const WTF::String& identifier, WebKit::WebInspectorUIExtensionControllerProxy&); 46 46 47 47 const WTF::String& identifier() const { return m_identifier; } 48 48 49 void createTab(const WTF::String& tabName, const WTF::URL& tabIconURL, const WTF::URL& sourceURL, WTF::CompletionHandler<void(Expected<WebKit::InspectorExtensionTabID, WebKit::InspectorExtensionError>)>&&); 50 49 51 private: 52 InspectorExtension(const WTF::String& identifier, WebKit::WebInspectorUIExtensionControllerProxy&); 53 50 54 WTF::String m_identifier; 55 WeakPtr<WebKit::WebInspectorUIExtensionControllerProxy> m_extensionControllerProxy; 51 56 }; 52 57 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm
r269701 r270606 208 208 } 209 209 210 capturedBlock(nil, [[wrapper(API::InspectorExtension::create(protectedExtensionID.get() )) retain] autorelease]);210 capturedBlock(nil, [[wrapper(API::InspectorExtension::create(protectedExtensionID.get(), protectedSelf->_inspector->extensionController())) retain] autorelease]); 211 211 }); 212 212 #else -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h
r269701 r270606 24 24 */ 25 25 26 #pragma once 27 28 #import <WebKit/WKFoundation.h> 29 30 #if TARGET_OS_OSX 31 26 32 #import <Foundation/Foundation.h> 27 #import <WebKit/WKFoundation.h>28 33 29 34 NS_ASSUME_NONNULL_BEGIN … … 32 37 @interface _WKInspectorExtension : NSObject 33 38 39 - (instancetype)new NS_UNAVAILABLE; 34 40 - (instancetype)init NS_UNAVAILABLE; 41 42 /** 43 * @abstract Creates a new tab in the Web Inspector interface for this extension. 44 * @param tabName A localized display name for the tab. 45 * @param tabIconURL The location of an image resource to use for display in the created tab's title. 46 * @param sourceURL The location of the main resource to load in the new tab's iframe browsing context. 47 * @param completionHandler The completion handler to be called when creating a tab succeeds or fails. 48 */ 49 - (void)createTabWithName:(NSString *)tabName tabIconURL:(NSURL *)tabIconURL sourceURL:(NSURL *)sourceURL completionHandler:(void(^)(NSError * _Nullable, NSString * _Nullable inspectorTabID))completionHandler; 35 50 36 51 @property (readonly, nonatomic) NSString *extensionID; … … 39 54 40 55 NS_ASSUME_NONNULL_END 56 57 #endif // TARGET_OS_OSX -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.mm
r269701 r270606 27 27 #import "_WKInspectorExtensionInternal.h" 28 28 29 NS_ASSUME_NONNULL_BEGIN 29 #if ENABLE(INSPECTOR_EXTENSIONS) 30 30 31 31 @implementation _WKInspectorExtension 32 33 #if ENABLE(INSPECTOR_EXTENSIONS)34 35 - (instancetype)initWithIdentifier:(NSString *)extensionID36 {37 if (!(self = [super init]))38 return nil;39 40 API::Object::constructInWrapper<API::InspectorExtension>(self, extensionID);41 42 return self;43 }44 32 45 33 - (void)dealloc … … 50 38 } 51 39 52 53 40 - (API::Object&)_apiObject 54 41 { 55 42 return *_extension; 43 } 44 45 // MARK: API 46 47 - (void)createTabWithName:(NSString *)tabName tabIconURL:(NSURL *)tabIconURL sourceURL:(NSURL *)sourceURL completionHandler:(void(^)(NSError *, NSString *))completionHandler 48 { 49 _extension->createTab(tabName, tabIconURL, sourceURL, [protectedSelf = retainPtr(self), capturedBlock = makeBlockPtr(completionHandler)] (Expected<WebKit::InspectorExtensionTabID, WebKit::InspectorExtensionError> result) mutable { 50 if (!result) { 51 capturedBlock([NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:@{ NSLocalizedFailureReasonErrorKey: inspectorExtensionErrorToString(result.error())}], nil); 52 return; 53 } 54 55 capturedBlock(nil, result.value()); 56 }); 56 57 } 57 58 … … 63 64 } 64 65 65 #endif // ENABLE(INSPECTOR_EXTENSIONS)66 67 66 @end 68 67 69 NS_ASSUME_NONNULL_END 68 #endif // ENABLE(INSPECTOR_EXTENSIONS) -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionInternal.h
r269701 r270606 39 39 } // namespace WebKit 40 40 41 NS_ASSUME_NONNULL_BEGIN42 43 41 @interface _WKInspectorExtension () <WKObject> { 44 42 @package … … 46 44 } 47 45 48 - (instancetype)initWithIdentifier:(NSString *)extensionIdentifier;49 50 46 @end 51 47 52 NS_ASSUME_NONNULL_END53 54 48 #endif // ENABLE(INSPECTOR_EXTENSIONS) -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm
r269701 r270606 25 25 26 26 #import "config.h" 27 #import "_WKRemoteWebInspectorViewController Private.h"27 #import "_WKRemoteWebInspectorViewControllerInternal.h" 28 28 29 29 #if PLATFORM(MAC) … … 88 88 89 89 @implementation _WKRemoteWebInspectorViewController { 90 RefPtr<WebKit::RemoteWebInspectorProxy> m_remoteInspectorProxy;91 90 std::unique_ptr<WebKit::_WKRemoteWebInspectorProxyClient> m_remoteInspectorClient; 92 91 _WKInspectorConfiguration *_configuration; … … 202 201 } 203 202 204 capturedBlock(nil, [[wrapper(API::InspectorExtension::create(protectedExtensionID.get() )) retain] autorelease]);203 capturedBlock(nil, [[wrapper(API::InspectorExtension::create(protectedExtensionID.get(), protectedSelf->m_remoteInspectorProxy->extensionController())) retain] autorelease]); 205 204 }); 206 205 #else -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerInternal.h
r270605 r270606 24 24 */ 25 25 26 #import <Foundation/Foundation.h> 27 #import <WebKit/WKFoundation.h> 26 #import "_WKRemoteWebInspectorViewControllerPrivate.h" 27 28 #if !TARGET_OS_IPHONE 29 30 namespace WebKit { 31 class RemoteWebInspectorProxy; 32 } 28 33 29 34 NS_ASSUME_NONNULL_BEGIN 30 35 31 WK_CLASS_AVAILABLE(macos(WK_MAC_TBA)) 32 @interface _WKInspectorExtension : NSObject 33 34 - (instancetype)init NS_UNAVAILABLE; 35 36 @property (readonly, nonatomic) NSString *extensionID; 37 36 @interface _WKRemoteWebInspectorViewController () { 37 @package 38 RefPtr<WebKit::RemoteWebInspectorProxy> m_remoteInspectorProxy; 39 } 38 40 @end 39 41 40 42 NS_ASSUME_NONNULL_END 43 44 #endif // !TARGET_OS_IPHONE -
trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp
r269701 r270606 99 99 } 100 100 101 void WebInspectorUIExtensionControllerProxy::createTabForExtension(const InspectorExtensionID& extensionID, const String& tabName, const URL& tabIconURL, const URL& sourceURL, WTF::CompletionHandler<void(Expected<InspectorExtensionTabID, InspectorExtensionError>)>&& completionHandler) 102 { 103 whenFrontendHasLoaded([weakThis = makeWeakPtr(this), extensionID, tabName, tabIconURL, sourceURL, completionHandler = WTFMove(completionHandler)] () mutable { 104 if (!weakThis || !weakThis->m_inspectorPage) { 105 completionHandler(makeUnexpected(InspectorExtensionError::InvalidRequest)); 106 return; 107 } 108 109 weakThis->m_inspectorPage->sendWithAsyncReply(Messages::WebInspectorUIExtensionController::CreateTabForExtension { extensionID, tabName, tabIconURL, sourceURL }, WTFMove(completionHandler)); 110 }); 111 } 112 101 113 } // namespace WebKit 102 114 -
trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h
r269701 r270606 50 50 void registerExtension(const InspectorExtensionID&, const String& displayName, WTF::CompletionHandler<void(Expected<bool, InspectorExtensionError>)>&&); 51 51 void unregisterExtension(const InspectorExtensionID&, WTF::CompletionHandler<void(Expected<bool, InspectorExtensionError>)>&&); 52 void createTabForExtension(const InspectorExtensionID&, const String& tabName, const URL& tabIconURL, const URL& sourceURL, WTF::CompletionHandler<void(Expected<InspectorExtensionTabID, InspectorExtensionError>)>&&); 52 53 53 54 // Notifications. -
trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h
r270130 r270606 45 45 46 46 void commitStateBeforeChildren(const WebCore::ScrollingStateNode&) override; 47 WebCore::WheelEventHandlingResult handleWheelEvent(const WebCore::PlatformWheelEvent&, EventTargeting) override;47 WebCore::WheelEventHandlingResult handleWheelEvent(const WebCore::PlatformWheelEvent&, WebCore::EventTargeting) override; 48 48 void repositionRelatedLayers() override; 49 49 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r270587 r270606 4739 4739 99996A9E25004BCB004F7559 /* _WKInspectorTesting.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInspectorTesting.mm; sourceTree = "<group>"; }; 4740 4740 999B7ED82550E4A800F450A4 /* InspectorExtensionTypes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorExtensionTypes.cpp; sourceTree = "<group>"; }; 4741 999B7F4F2554BA3F00F450A4 /* APIInspectorExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIInspectorExtension.cpp; sourceTree = "<group>"; }; 4741 4742 99B16754252BB7E00073140E /* _WKInspectorExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorExtension.h; sourceTree = "<group>"; }; 4742 4743 99B16755252BB7E10073140E /* _WKInspectorExtensionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorExtensionInternal.h; sourceTree = "<group>"; }; … … 9656 9657 994C6048253F820200BDF060 /* APIInspectorConfiguration.cpp */, 9657 9658 994C6046253CACB800BDF060 /* APIInspectorConfiguration.h */, 9659 999B7F4F2554BA3F00F450A4 /* APIInspectorExtension.cpp */, 9658 9660 99BE3B1225422F4100C6551C /* APIInspectorExtension.h */, 9659 9661 31B362902141EABC007BFA53 /* APIInternalDebugFeature.cpp */, -
trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp
r270573 r270606 57 57 Optional<InspectorExtensionError> WebInspectorUIExtensionController::parseInspectorExtensionErrorFromEvaluationResult(InspectorFrontendAPIDispatcher::EvaluationResult result) 58 58 { 59 if (!result .has_value()) {59 if (!result) { 60 60 switch (result.error()) { 61 61 case WebCore::InspectorFrontendAPIDispatcher::EvaluationError::ContextDestroyed: … … 150 150 } 151 151 152 JSC::JSObject* WebInspectorUIExtensionController::unwrapEvaluationResultAsObject(InspectorFrontendAPIDispatcher::EvaluationResult result) 153 { 154 if (!result) 155 return nullptr; 156 157 auto valueOrException = result.value(); 158 if (!valueOrException.has_value()) 159 return nullptr; 160 161 return valueOrException.value().getObject(); 162 } 163 164 void WebInspectorUIExtensionController::createTabForExtension(const InspectorExtensionID& extensionID, const String& tabName, const URL& tabIconURL, const URL& sourceURL, WTF::CompletionHandler<void(Expected<InspectorExtensionTabID, InspectorExtensionError>)>&& completionHandler) 165 { 166 if (!m_frontendClient) { 167 completionHandler(makeUnexpected(InspectorExtensionError::InvalidRequest)); 168 return; 169 } 170 171 Vector<Ref<JSON::Value>> arguments { 172 JSON::Value::create(extensionID), 173 JSON::Value::create(tabName), 174 JSON::Value::create(tabIconURL.string()), 175 JSON::Value::create(sourceURL.string()), 176 }; 177 m_frontendClient->frontendAPIDispatcher().dispatchCommandWithResultAsync("createTabForExtension"_s, WTFMove(arguments), [weakThis = makeWeakPtr(this), completionHandler = WTFMove(completionHandler)](InspectorFrontendAPIDispatcher::EvaluationResult&& result) mutable { 178 if (!weakThis || !result) { 179 completionHandler(makeUnexpected(InspectorExtensionError::ContextDestroyed)); 180 return; 181 } 182 183 if (auto parsedError = weakThis->parseInspectorExtensionErrorFromEvaluationResult(result.value())) { 184 completionHandler(makeUnexpected(parsedError.value())); 185 return; 186 } 187 188 // Expected result is either an ErrorString or {extensionTabID: <string>}. 189 auto objectResult = weakThis->unwrapEvaluationResultAsObject(result); 190 if (!objectResult) { 191 LOG(Inspector, "Unexpected non-object value returned from InspectorFrontendAPI.createTabForExtension()."); 192 completionHandler(makeUnexpected(InspectorExtensionError::InternalError)); 193 return; 194 } 195 196 auto* frontendGlobalObject = weakThis->m_frontendClient->frontendAPIDispatcher().frontendGlobalObject(); 197 JSC::JSValue foundProperty = objectResult->get(frontendGlobalObject, JSC::Identifier::fromString(frontendGlobalObject->vm(), "extensionTabID"_s)); 198 if (!foundProperty || !foundProperty.isString()) { 199 completionHandler(makeUnexpected(InspectorExtensionError::InternalError)); 200 return; 201 } 202 203 completionHandler({ foundProperty.toWTFString(frontendGlobalObject) }); 204 }); 205 } 206 152 207 } // namespace WebKit 153 208 -
trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h
r270453 r270606 65 65 void registerExtension(const InspectorExtensionID&, const String& displayName, CompletionHandler<void(Expected<bool, InspectorExtensionError>)>&&); 66 66 void unregisterExtension(const InspectorExtensionID&, CompletionHandler<void(Expected<bool, InspectorExtensionError>)>&&); 67 void createTabForExtension(const InspectorExtensionID&, const String& tabName, const URL& tabIconURL, const URL& sourceURL, WTF::CompletionHandler<void(Expected<InspectorExtensionTabID, InspectorExtensionError>)>&&); 67 68 68 69 private: 70 JSC::JSObject* unwrapEvaluationResultAsObject(WebCore::InspectorFrontendAPIDispatcher::EvaluationResult); 69 71 Optional<InspectorExtensionError> parseInspectorExtensionErrorFromEvaluationResult(WebCore::InspectorFrontendAPIDispatcher::EvaluationResult); 70 72 -
trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.messages.in
r269701 r270606 26 26 RegisterExtension(String extensionID, String displayName) -> (Expected<bool, WebKit::InspectorExtensionError> result) Async 27 27 UnregisterExtension(String extensionID) -> (Expected<bool, WebKit::InspectorExtensionError> result) Async 28 29 CreateTabForExtension(String extensionID, String tabName, URL tabIconURL, URL sourceURL) -> (Expected<String, WebKit::InspectorExtensionError> result) Async 28 30 } 29 31
Note:
See TracChangeset
for help on using the changeset viewer.