Changeset 292084 in webkit
- Timestamp:
- Mar 29, 2022 5:12:28 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 44 edited
- 1 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/http/tests/inspector/network/local-resource-override-mapped-to-file-expected.txt (added)
-
LayoutTests/http/tests/inspector/network/local-resource-override-mapped-to-file.html (added)
-
LayoutTests/platform/mac-wk1/TestExpectations (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/inspector/InspectorFrontendClient.h (modified) (1 diff)
-
Source/WebCore/inspector/InspectorFrontendClientLocal.h (modified) (1 diff)
-
Source/WebCore/inspector/InspectorFrontendHost.cpp (modified) (3 diffs)
-
Source/WebCore/inspector/InspectorFrontendHost.h (modified) (2 diffs)
-
Source/WebCore/inspector/InspectorFrontendHost.idl (modified) (1 diff)
-
Source/WebCore/testing/Internals.cpp (modified) (2 diffs)
-
Source/WebCore/testing/Internals.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.idl (modified) (1 diff)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (modified) (2 diffs)
-
Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js (modified) (4 diffs)
-
Source/WebInspectorUI/UserInterface/Images/Disk.svg (added)
-
Source/WebInspectorUI/UserInterface/Main.html (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Models/LocalResource.js (modified) (5 diffs)
-
Source/WebInspectorUI/UserInterface/Models/LocalResourceOverride.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Views/ResourceContentView.css (copied) (copied from trunk/Source/WebKit/WebProcess/Inspector/win/WebInspectorUIWin.cpp) (2 diffs)
-
Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js (modified) (7 diffs)
-
Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp (modified) (4 diffs)
-
Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.h (modified) (3 diffs)
-
Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in (modified) (1 diff)
-
Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.messages.in (modified) (1 diff)
-
Source/WebKit/UIProcess/Inspector/glib/RemoteInspectorClient.cpp (modified) (3 diffs)
-
Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/Inspector/win/WebInspectorUIProxyWin.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h (modified) (2 diffs)
-
Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/Inspector/WebInspectorUI.h (modified) (1 diff)
-
Source/WebKit/WebProcess/Inspector/gtk/WebInspectorUIGtk.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm (modified) (1 diff)
-
Source/WebKit/WebProcess/Inspector/win/WebInspectorUIWin.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r292079 r292084 1 2022-03-29 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Sources: allow Response Local Overrides to map to a file on disk 4 https://bugs.webkit.org/show_bug.cgi?id=238236 5 <rdar://problem/59009154> 6 7 Reviewed by Patrick Angle. 8 9 * http/tests/inspector/network/local-resource-override-mapped-to-file.html: Added. 10 * http/tests/inspector/network/local-resource-override-mapped-to-file-expected.txt: Added. 11 12 * TestExpectations: 13 * platform/mac-wk1/TestExpectations: 14 * platform/mac-wk2/TestExpectations: 15 Skip this test everywhere except mac-wk2. 16 1 17 2022-03-29 Matt Woodrow <mattwoodrow@apple.com> 2 18 -
trunk/LayoutTests/TestExpectations
r292079 r292084 1243 1243 inspector/page/overrideSetting-PrivateClickMeasurementDebugModeEnabled.html [ Skip ] 1244 1244 inspector/page/overrideSetting-ITPDebugModeEnabled.html [ Skip ] 1245 1246 # Network interception with a mapped file is only mac-wk2 for now. 1247 http/tests/inspector/network/local-resource-override-mapped-to-file.html [ Skip ] 1245 1248 1246 1249 # These conformance tests are no longer in sync with the latest specification -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r291948 r292084 926 926 http/tests/inspector/network/local-resource-override-basic.html [ Skip ] 927 927 http/tests/inspector/network/local-resource-override-main-resource.html [ Skip ] 928 http/tests/inspector/network/local-resource-override-mapped-to-file.html [ Skip ] 928 929 http/tests/inspector/network/local-resource-override-script-tag.html [ Skip ] 929 930 http/tests/inspector/network/resource-response-inspector-override.html [ Skip ] -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r291948 r292084 692 692 [ Mojave Catalina ] accessibility/mac/isolated-tree-mode-on-off.html [ Skip ] 693 693 694 # Network interception with a mapped file is only mac-wk2 for now. 695 http/tests/inspector/network/local-resource-override-mapped-to-file.html [ Pass ] 696 694 697 # Content Extensions tests must be enabled explicitly on mac-wk2. 695 698 http/tests/contentextensions [ Pass ] -
trunk/Source/WebCore/ChangeLog
r292079 r292084 1 2022-03-29 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Sources: allow Response Local Overrides to map to a file on disk 4 https://bugs.webkit.org/show_bug.cgi?id=238236 5 <rdar://problem/59009154> 6 7 Reviewed by Patrick Angle. 8 9 This makes Response Local Overrides even more powerful by allowing developers to map the 10 contents of the (Local Override) resource to a file on disk (e.g. a local copy of the file), 11 meaning that they can use their preferred editor of choice (and all the tools that may come 12 with it) to make changes instead of having to stay within Web Inspector. 13 14 Test: http/tests/inspector/network/local-resource-override-mapped-to-file.html 15 16 * inspector/InspectorFrontendHost.idl: 17 * inspector/InspectorFrontendHost.h: 18 * inspector/InspectorFrontendHost.cpp: 19 (WebCore::InspectorFrontendHost::canLoad): Added. 20 (WebCore::InspectorFrontendHost::load): Added. 21 (WebCore::InspectorFrontendHost::getPath): Added. 22 Add helpers for loading the contents of a file on disk and getting the full path of a `File`. 23 24 * inspector/InspectorFrontendClient.h: 25 * inspector/InspectorFrontendClientLocal.h: 26 (WebCore::InspectorFrontendClientLocal::canLoad): Added. 27 (WebCore::InspectorFrontendClientLocal::load): Added. 28 Do not allow file mapping in tests (and WK1). 29 30 * testing/Internals.idl: 31 * testing/Internals.h: 32 * testing/Internals.cpp: 33 (WebCore::Internals::createTemporaryFile): Added. 34 Add a way for tests to create a temporary file with given contents. 35 1 36 2022-03-29 Matt Woodrow <mattwoodrow@apple.com> 2 37 -
trunk/Source/WebCore/inspector/InspectorFrontendClient.h
r288999 r292084 110 110 virtual void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs) = 0; 111 111 virtual void append(const String& url, const String& content) = 0; 112 virtual bool canLoad() = 0; 113 virtual void load(const String& path, CompletionHandler<void(const String&)>&&) = 0; 112 114 113 115 virtual void inspectedURLChanged(const String&) = 0; -
trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h
r278253 r292084 84 84 void save(const String&, const String&, bool, bool) override { } 85 85 void append(const String&, const String&) override { } 86 bool canLoad() override { return false; } 87 void load(const String&, CompletionHandler<void(const String&)>&& completionHandler) override { completionHandler(nullString()); } 86 88 87 89 virtual void attachWindow(DockSide) = 0; -
trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp
r291992 r292084 40 40 #include "Editor.h" 41 41 #include "Event.h" 42 #include "File.h" 42 43 #include "FloatRect.h" 43 44 #include "FocusController.h" … … 50 51 #include "JSDOMConvertInterface.h" 51 52 #include "JSDOMExceptionHandling.h" 53 #include "JSDOMPromiseDeferred.h" 52 54 #include "JSExecState.h" 53 55 #include "JSInspectorFrontendHost.h" … … 461 463 } 462 464 465 bool InspectorFrontendHost::canLoad() 466 { 467 if (m_client) 468 return m_client->canLoad(); 469 return false; 470 } 471 472 void InspectorFrontendHost::load(const String& path, Ref<DeferredPromise>&& promise) 473 { 474 if (!m_client) { 475 promise->reject(InvalidStateError); 476 return; 477 } 478 479 m_client->load(path, [promise = WTFMove(promise)](const String& content) { 480 if (!content) 481 promise->reject(NotFoundError); 482 else 483 promise->resolve<IDLDOMString>(content); 484 }); 485 } 486 463 487 void InspectorFrontendHost::close(const String&) 464 488 { 489 } 490 491 String InspectorFrontendHost::getPath(const File& file) 492 { 493 return file.path(); 465 494 } 466 495 -
trunk/Source/WebCore/inspector/InspectorFrontendHost.h
r288999 r292084 39 39 40 40 class DOMWrapperWorld; 41 class DeferredPromise; 41 42 class Event; 43 class File; 42 44 class FrontendMenuProvider; 43 45 class HTMLIFrameElement; … … 110 112 void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs); 111 113 void append(const String& url, const String& content); 114 bool canLoad(); 115 void load(const String& path, Ref<DeferredPromise>&&); 112 116 void close(const String& url); 117 118 String getPath(const File&); 113 119 114 120 struct ContextMenuItem { -
trunk/Source/WebCore/inspector/InspectorFrontendHost.idl
r288999 r292084 75 75 undefined save(DOMString url, DOMString content, boolean base64Encoded, boolean forceSaveAs); 76 76 undefined append(DOMString url, DOMString content); 77 boolean canLoad(); 78 [NewObject] Promise<DOMString> load(DOMString path); 77 79 undefined close(DOMString url); 80 81 DOMString getPath(File file); 78 82 79 83 readonly attribute DOMString port; -
trunk/Source/WebCore/testing/Internals.cpp
r292027 r292084 235 235 #include <JavaScriptCore/JSCInlines.h> 236 236 #include <JavaScriptCore/JSCJSValue.h> 237 #include <wtf/FileSystem.h> 237 238 #include <wtf/HexNumber.h> 238 239 #include <wtf/JSONValues.h> … … 4872 4873 } 4873 4874 4875 String Internals::createTemporaryFile(const String& name, const String& contents) 4876 { 4877 if (name.isEmpty()) 4878 return nullString(); 4879 4880 auto file = FileSystem::invalidPlatformFileHandle; 4881 auto path = FileSystem::openTemporaryFile(makeString("WebCoreTesting-", name), file); 4882 if (!FileSystem::isHandleValid(file)) 4883 return nullString(); 4884 4885 auto contentsUTF8 = contents.utf8(); 4886 FileSystem::writeToFile(file, contentsUTF8.data(), contentsUTF8.length()); 4887 4888 FileSystem::closeFile(file); 4889 4890 return path; 4891 } 4892 4874 4893 void Internals::queueMicroTask(int testNumber) 4875 4894 { -
trunk/Source/WebCore/testing/Internals.h
r291846 r292084 777 777 778 778 RefPtr<File> createFile(const String&); 779 String createTemporaryFile(const String& name, const String& contents); 780 779 781 void queueMicroTask(int); 780 782 bool testPreloaderSettingViewport(); -
trunk/Source/WebCore/testing/Internals.idl
r291846 r292084 843 843 844 844 File? createFile(DOMString url); 845 DOMString createTemporaryFile(DOMString name, DOMString contents); 846 845 847 undefined queueMicroTask(long testNumber); 846 848 boolean testPreloaderSettingViewport(); -
trunk/Source/WebInspectorUI/ChangeLog
r292037 r292084 1 2022-03-29 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Sources: allow Response Local Overrides to map to a file on disk 4 https://bugs.webkit.org/show_bug.cgi?id=238236 5 <rdar://problem/59009154> 6 7 Reviewed by Patrick Angle. 8 9 This makes Response Local Overrides even more powerful by allowing developers to map the 10 contents of the (Local Override) resource to a file on disk (e.g. a local copy of the file), 11 meaning that they can use their preferred editor of choice (and all the tools that may come 12 with it) to make changes instead of having to stay within Web Inspector. 13 14 * UserInterface/Models/LocalResource.js: 15 (WI.LocalResource): 16 (WI.LocalResource.canMapToFile): Added. 17 (WI.LocalResource.prototype.toJSON): 18 (WI.LocalResource.prototype.get mappedFilePath): Added. 19 (WI.LocalResource.prototype.set mappedFilePath): Added. 20 (WI.LocalResource.prototype.async requestContent): 21 (WI.LocalResource.prototype.async _loadFromFileSystem): Added. 22 * UserInterface/Models/LocalResourceOverride.js: 23 (WI.LocalResourceOverride.prototype.get canMapToFile): Added. 24 Save the given local file path as a member variable and use `InspectorFrontendHost.load` to 25 grab its contents (saving it inside the `WI.LocalResource` so that it can still be used in 26 case the file is moved/deleted) whenever anyone `requestContent`. 27 28 * UserInterface/Views/ResourceContentView.js: 29 (WI.ResourceContentView): 30 (WI.ResourceContentView.prototype.get navigationItems): 31 (WI.ResourceContentView.prototype.showMessage): 32 (WI.ResourceContentView.prototype.addIssue): 33 (WI.ResourceContentView.prototype._contentAvailable): 34 (WI.ResourceContentView.prototype.async _handleMapLocalResourceOverrideToFile): Added. 35 (WI.ResourceContentView.prototype._handleMappedFilePathChanged): Added. 36 Add a new "[Disk.svg] Map to File" navigation item when viewing Response Local Overrides. If 37 the Response Local Override has already been mapped to a file, show the path of the file 38 instead of the contents of the resource. This allows us to not have to monitor the file for 39 changes, instead only grabbing the current contents when necessary (i.e. when replacing the 40 response of an intercepted network request). 41 42 * UserInterface/Views/ResourceContentView.css: Added. 43 (.content-view.resource > .local-resource-override-label-view + .message-text-view): 44 Still show the Local Override banner if the Local Override has been mapped to a file. 45 46 * UserInterface/Views/TextResourceContentView.js: 47 (WI.TextResourceContentView.prototype._contentWillPopulate): 48 Don't show the `WI.SourceCodeTextEditor` if there's already something else being shown. 49 50 * UserInterface/Controllers/NetworkManager.js: 51 (WI.NetworkManager.prototype.async requestIntercepted): 52 (WI.NetworkManager.prototype.async responseIntercepted): 53 Make sure to `requestContent` before using the `currentRevision` so that any file-mapped 54 `WI.LocalResource` have a chance to load from disk before handling the interception. 55 56 * Localizations/en.lproj/localizedStrings.js: 57 * UserInterface/Main.html: 58 * UserInterface/Images/Disk.svg: Added. 59 1 60 2022-03-29 Patrick Angle <pangle@apple.com> 2 61 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r292037 r292084 890 890 localizedStrings["Local File"] = "Local File"; 891 891 localizedStrings["Local Override"] = "Local Override"; 892 localizedStrings["Local Override: could not load \u201C%s\u201D"] = "Local Override: could not load \u201C%s\u201D"; 892 893 localizedStrings["Local Override\u2026"] = "Local Override\u2026"; 893 894 localizedStrings["Local Overrides"] = "Local Overrides"; … … 923 924 localizedStrings["Main: %s"] = "Main: %s"; 924 925 localizedStrings["Manifest URL"] = "Manifest URL"; 926 localizedStrings["Map to File"] = "Map to File"; 927 localizedStrings["Mapped to \u201C%s\u201D"] = "Mapped to \u201C%s\u201D"; 925 928 localizedStrings["Mass"] = "Mass"; 926 929 localizedStrings["Matching"] = "Matching"; -
trunk/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js
r270604 r292084 947 947 } 948 948 949 requestIntercepted(target, requestId, request)949 async requestIntercepted(target, requestId, request) 950 950 { 951 951 let url = WI.urlWithoutFragment(request.url); … … 955 955 956 956 let localResource = localResourceOverride.localResource; 957 await localResource.requestContent(); 958 957 959 let revision = localResource.currentRevision; 958 960 … … 993 995 } 994 996 995 responseIntercepted(target, requestId, response)997 async responseIntercepted(target, requestId, response) 996 998 { 997 999 let url = WI.urlWithoutFragment(response.url); … … 1001 1003 1002 1004 let localResource = localResourceOverride.localResource; 1005 await localResource.requestContent(); 1006 1003 1007 let revision = localResource.currentRevision; 1004 1008 -
trunk/Source/WebInspectorUI/UserInterface/Main.html
r291093 r292084 195 195 <link rel="stylesheet" href="Views/Resizer.css"> 196 196 <link rel="stylesheet" href="Views/ResourceCollectionContentView.css"> 197 <link rel="stylesheet" href="Views/ResourceContentView.css"> 197 198 <link rel="stylesheet" href="Views/ResourceCookiesContentView.css"> 198 199 <link rel="stylesheet" href="Views/ResourceDetailsSection.css"> -
trunk/Source/WebInspectorUI/UserInterface/Models/LocalResource.js
r292037 r292084 37 37 WI.LocalResource = class LocalResource extends WI.Resource 38 38 { 39 constructor({request, response, metrics, timing })39 constructor({request, response, metrics, timing, mappedFilePath}) 40 40 { 41 41 console.assert(request); … … 88 88 this._originalRevision = new WI.SourceCodeRevision(this, content, base64Encoded, this._mimeType); 89 89 this._currentRevision = this._originalRevision; 90 91 this._mappedFilePath = mappedFilePath || null; 90 92 } 91 93 92 94 // Static 95 96 static canMapToFile() 97 { 98 return InspectorFrontendHost.canLoad(); 99 } 93 100 94 101 static headersArrayToHeadersObject(headers) … … 228 235 base64Encoded: this.currentRevision.base64Encoded, 229 236 }, 237 mappedFilePath: this._mappedFilePath, 230 238 }; 231 239 } … … 235 243 get localResourceOverride() { return this._localResourceOverride; } 236 244 245 get mappedFilePath() 246 { 247 return this._mappedFilePath; 248 } 249 250 set mappedFilePath(mappedFilePath) 251 { 252 console.assert(WI.LocalResource.canMapToFile()); 253 console.assert(mappedFilePath); 254 255 if (mappedFilePath === this._mappedFilePath) 256 return; 257 258 this._mappedFilePath = mappedFilePath; 259 260 const forceUpdate = true; 261 this._loadFromFileSystem(forceUpdate).then(() => { 262 this.dispatchEventToListeners(WI.LocalResource.Event.MappedFilePathChanged); 263 }); 264 } 265 237 266 // Protected 267 268 async requestContent() 269 { 270 await this._loadFromFileSystem(); 271 272 return super.requestContent(); 273 } 238 274 239 275 requestContentFromBackend() … … 253 289 } 254 290 } 291 292 // Private 293 294 async _loadFromFileSystem(forceUpdate) 295 { 296 if (!this._mappedFilePath) 297 return; 298 299 let content = ""; 300 try { 301 content = await InspectorFrontendHost.load(this._mappedFilePath); 302 } catch { 303 if (this._didWarnAboutFailureToLoadFromFileSystem) 304 return; 305 306 this._didWarnAboutFailureToLoadFromFileSystem = true; 307 setTimeout(() => { 308 this._didWarnAboutFailureToLoadFromFileSystem = false; 309 }); 310 311 let message = WI.UIString("Local Override: could not load \u201C%s\u201D").format(this._mappedFilePath); 312 313 if (window.InspectorTest) { 314 console.warn(message); 315 return; 316 } 317 318 let consoleMessage = new WI.ConsoleMessage(WI.mainTarget, WI.ConsoleMessage.MessageSource.Other, WI.ConsoleMessage.MessageLevel.Warning, message); 319 consoleMessage.shouldRevealConsole = true; 320 321 WI.consoleLogViewController.appendConsoleMessage(consoleMessage); 322 return; 323 } 324 325 if (!forceUpdate && content === this.currentRevision.content) 326 return; 327 328 this.editableRevision.updateRevisionContent(content); 329 } 255 330 }; 331 332 WI.LocalResource.Event = { 333 MappedFilePathChanged: "local-resource-mapped-file-path-changed", 334 }; -
trunk/Source/WebInspectorUI/UserInterface/Models/LocalResourceOverride.js
r270604 r292084 165 165 } 166 166 167 get canMapToFile() 168 { 169 if (!WI.LocalResource.canMapToFile()) 170 return false; 171 172 switch (this._type) { 173 case WI.LocalResourceOverride.InterceptType.Request: 174 return false; 175 176 case WI.LocalResourceOverride.InterceptType.Response: 177 case WI.LocalResourceOverride.InterceptType.ResponseSkippingNetwork: 178 return true; 179 } 180 181 console.assert(false, "not reached"); 182 return false; 183 } 184 167 185 matches(url) 168 186 { -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.css
r292083 r292084 1 1 /* 2 * Copyright (C) 20 17 Sony Interactive Entertainment Inc.2 * Copyright (C) 2022 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 #include "config.h" 27 #include "WebInspectorUI.h" 28 29 #include "RemoteWebInspectorUI.h" 30 31 #include <WebCore/WebCoreBundleWin.h> 32 #include <wtf/FileSystem.h> 33 #include <wtf/text/WTFString.h> 34 35 namespace WebKit { 36 37 bool WebInspectorUI::canSave() 38 { 39 return false; 26 .content-view.resource > .local-resource-override-label-view + .message-text-view { 27 top: var(--navigation-bar-height); 40 28 } 41 42 String WebInspectorUI::localizedStringsURL() const43 {44 return "inspector-resource:///localizedStrings.js"_s;45 }46 47 String RemoteWebInspectorUI::localizedStringsURL() const48 {49 return "inspector-resource:///localizedStrings.js"_s;50 }51 52 } // namespace WebKit -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js
r276144 r292084 38 38 39 39 this._spinnerTimeout = setTimeout(() => { 40 // Append a spinner while waiting for contentAvailable. Subclasses are responsible for 41 // removing the spinner before showing the resource content by calling removeLoadingIndicator. 42 let spinner = new WI.IndeterminateProgressSpinner; 43 this.element.appendChild(spinner.element); 40 if (!this._hasContent()) { 41 // Append a spinner while waiting for contentAvailable. Subclasses are responsible for 42 // removing the spinner before showing the resource content by calling removeLoadingIndicator. 43 let spinner = new WI.IndeterminateProgressSpinner; 44 this.element.appendChild(spinner.element); 45 } 44 46 45 47 this._spinnerTimeout = undefined; … … 67 69 this._importLocalResourceOverrideButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low; 68 70 this._importLocalResourceOverrideButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleImportLocalResourceOverride, this); 71 72 if (resource.localResourceOverride.canMapToFile) { 73 this._mapLocalResourceOverrideToFileButtonNavigationItem = new WI.ButtonNavigationItem("map-local-resource-override", WI.UIString("Map to File"), "Images/Disk.svg", 15, 15); 74 this._mapLocalResourceOverrideToFileButtonNavigationItem.buttonStyle = WI.ButtonNavigationItem.Style.ImageAndText; 75 this._mapLocalResourceOverrideToFileButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low; 76 this._mapLocalResourceOverrideToFileButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleMapLocalResourceOverrideToFile, this); 77 78 resource.addEventListener(WI.LocalResource.Event.MappedFilePathChanged, this._handleMappedFilePathChanged, this); 79 } 69 80 70 81 this._removeLocalResourceOverrideButtonNavigationItem = new WI.ButtonNavigationItem("remove-local-resource-override", WI.UIString("Delete Local Override"), "Images/NavigationItemTrash.svg", 15, 15); … … 97 108 98 109 if (this._importLocalResourceOverrideButtonNavigationItem) 99 items.push(this._importLocalResourceOverrideButtonNavigationItem, new WI.DividerNavigationItem); 110 items.push(this._importLocalResourceOverrideButtonNavigationItem); 111 if (this._mapLocalResourceOverrideToFileButtonNavigationItem) 112 items.push(this._mapLocalResourceOverrideToFileButtonNavigationItem); 113 114 if (items.length) 115 items.push(new WI.DividerNavigationItem); 116 100 117 if (this._removeLocalResourceOverrideButtonNavigationItem) 101 118 items.push(this._removeLocalResourceOverrideButtonNavigationItem); … … 173 190 showMessage(message) 174 191 { 175 this.element.removeChildren(); 192 this.removeAllSubviews(); 193 176 194 this.element.appendChild(WI.createMessageTextView(message)); 177 195 } … … 180 198 { 181 199 // This generically shows only the last issue, subclasses can override for better handling. 182 this.element.removeChildren(); 200 this.removeAllSubviews(); 201 183 202 this.element.appendChild(WI.createMessageTextView(issue.text, issue.level === WI.IssueMessage.Level.Error)); 184 203 } … … 230 249 this.showMessage(parameters.message); 231 250 return; 251 } 252 253 if (parameters.sourceCode instanceof WI.LocalResource) { 254 if (this.resource.mappedFilePath) { 255 this._handleMappedFilePathChanged(); 256 return; 257 } 232 258 } 233 259 … … 348 374 } 349 375 376 _handleMapLocalResourceOverrideToFile(event) 377 { 378 WI.FileUtilities.import((files) => { 379 console.assert(files.length === 1, files); 380 381 this.resource.mappedFilePath = InspectorFrontendHost.getPath(files[0]); 382 }); 383 } 384 385 _handleMappedFilePathChanged(event) 386 { 387 this.showMessage(WI.UIString("Mapped to \u201C%s\u201D").format(this.resource.mappedFilePath)); 388 389 if (this._localResourceOverrideBannerView) { 390 this.element.insertBefore(this._localResourceOverrideBannerView.element, this.element.firstChild); 391 this.addSubview(this._localResourceOverrideBannerView); 392 } 393 } 394 350 395 _handleRemoveLocalResourceOverride(event) 351 396 { -
trunk/Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js
r270604 r292084 224 224 return; 225 225 226 if (this._hasContent()) 227 return; 228 226 229 this.removeLoadingIndicator(); 227 230 -
trunk/Source/WebKit/ChangeLog
r292081 r292084 1 2022-03-29 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: Sources: allow Response Local Overrides to map to a file on disk 4 https://bugs.webkit.org/show_bug.cgi?id=238236 5 <rdar://problem/59009154> 6 7 Reviewed by Patrick Angle. 8 9 This makes Response Local Overrides even more powerful by allowing developers to map the 10 contents of the (Local Override) resource to a file on disk (e.g. a local copy of the file), 11 meaning that they can use their preferred editor of choice (and all the tools that may come 12 with it) to make changes instead of having to stay within Web Inspector. 13 14 * WebProcess/Inspector/WebInspectorUI.h: 15 * WebProcess/Inspector/WebInspectorUI.cpp: 16 (WebKit::WebInspectorUI::load): Added. 17 (WebKit::WebInspectorUI::canLoad): Added. 18 * WebProcess/Inspector/gtk/WebInspectorUIGtk.cpp: 19 (WebKit::WebInspectorUI::canLoad): Added. 20 * WebProcess/Inspector/mac/WebInspectorUIMac.mm: 21 (WebKit::WebInspectorUI::canLoad): Added. 22 * WebProcess/Inspector/win/WebInspectorUIWin.cpp: 23 (WebKit::WebInspectorUI::canLoad): Added. 24 * WebProcess/Inspector/RemoteWebInspectorUI.h: 25 * WebProcess/Inspector/RemoteWebInspectorUI.cpp: 26 (WebKit::RemoteWebInspectorUI::load): Added. 27 * UIProcess/Inspector/WebInspectorUIProxy.messages.in: 28 * UIProcess/Inspector/WebInspectorUIProxy.h: 29 * UIProcess/Inspector/WebInspectorUIProxy.cpp: 30 (WebKit::WebInspectorUIProxy::load): Added. 31 (WebKit::WebInspectorUIProxy::platformLoad): Added. 32 * UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp: 33 (WebKit::WebInspectorUIProxy::platformLoad): Added. 34 * UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm: 35 (WebKit::WebInspectorUIProxy::platformLoad): Added. 36 * UIProcess/Inspector/win/WebInspectorUIProxyWin.cpp: 37 (WebKit::WebInspectorUIProxy::platformLoad): Added. 38 * UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in: 39 * UIProcess/Inspector/RemoteWebInspectorUIProxy.h: 40 * UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp: 41 (WebKit::RemoteWebInspectorUIProxy::initialize): Renamed from `load`. 42 (WebKit::RemoteWebInspectorUIProxy::reopen): 43 (WebKit::RemoteWebInspectorUIProxy::load): Added. 44 (WebKit::RemoteWebInspectorUIProxy::platformLoad): Added. 45 * UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp: 46 (WebKit::RemoteWebInspectorUIProxy::platformLoad): Added. 47 * UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm: 48 (WebKit::RemoteWebInspectorUIProxy::platformLoad): Added. 49 * UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp: 50 (WebKit::RemoteWebInspectorUIProxy::platformLoad): Added. 51 Add helpers for loading the contents of a file on disk. 52 53 * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm: 54 (-[_WKRemoteWebInspectorViewController loadForDebuggable:backendCommandsURL:]): 55 * UIProcess/Inspector/glib/RemoteInspectorClient.cpp: 56 (WebKit::RemoteInspectorProxy::initialize): Renamed from `load`. 57 (WebKit::RemoteInspectorClient::inspect): 58 * UIProcess/Inspector/socket/RemoteInspectorClient.cpp: 59 (WebKit::RemoteInspectorProxy::initialize): Renamed from `load`. 60 (WebKit::RemoteInspectorClient::inspect): 61 Use renamed `WebKit::RemoteWebInspectorUIProxy::initialize`. 62 1 63 2022-03-29 Jigen Zhou <jigen.zhou@sony.com> 2 64 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm
r286329 r292084 124 124 - (void)loadForDebuggable:(_WKInspectorDebuggableInfo *)debuggableInfo backendCommandsURL:(NSURL *)backendCommandsURL 125 125 { 126 m_remoteInspectorProxy-> load(static_cast<API::DebuggableInfo&>([debuggableInfo _apiObject]), backendCommandsURL.absoluteString);126 m_remoteInspectorProxy->initialize(static_cast<API::DebuggableInfo&>([debuggableInfo _apiObject]), backendCommandsURL.absoluteString); 127 127 } 128 128 -
trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp
r290394 r292084 68 68 } 69 69 70 void RemoteWebInspectorUIProxy:: load(Ref<API::DebuggableInfo>&& debuggableInfo, const String& backendCommandsURL)70 void RemoteWebInspectorUIProxy::initialize(Ref<API::DebuggableInfo>&& debuggableInfo, const String& backendCommandsURL) 71 71 { 72 72 m_debuggableInfo = WTFMove(debuggableInfo); … … 132 132 133 133 closeFrontendPageAndWindow(); 134 load(m_debuggableInfo.copyRef(), m_backendCommandsURL);134 initialize(m_debuggableInfo.copyRef(), m_backendCommandsURL); 135 135 } 136 136 … … 153 153 { 154 154 platformAppend(suggestedURL, content); 155 } 156 157 void RemoteWebInspectorUIProxy::load(const String& path, CompletionHandler<void(const String&)>&& completionHandler) 158 { 159 platformLoad(path, WTFMove(completionHandler)); 155 160 } 156 161 … … 234 239 void RemoteWebInspectorUIProxy::platformSave(const String&, const String&, bool, bool) { } 235 240 void RemoteWebInspectorUIProxy::platformAppend(const String&, const String&) { } 241 void RemoteWebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler) { completionHandler(nullString()); } 236 242 void RemoteWebInspectorUIProxy::platformSetSheetRect(const FloatRect&) { } 237 243 void RemoteWebInspectorUIProxy::platformSetForcedAppearance(InspectorFrontendClient::Appearance) { } -
trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.h
r283119 r292084 86 86 void invalidate(); 87 87 88 void load(Ref<API::DebuggableInfo>&&, const String& backendCommandsURL);88 void initialize(Ref<API::DebuggableInfo>&&, const String& backendCommandsURL); 89 89 void closeFromBackend(); 90 90 void show(); … … 134 134 void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs); 135 135 void append(const String& filename, const String& content); 136 void load(const String& path, CompletionHandler<void(const String&)>&&); 136 137 void setSheetRect(const WebCore::FloatRect&); 137 138 void setForcedAppearance(WebCore::InspectorFrontendClient::Appearance); … … 151 152 void platformSave(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs); 152 153 void platformAppend(const String& filename, const String& content); 154 void platformLoad(const String& path, CompletionHandler<void(const String&)>&&); 153 155 void platformSetSheetRect(const WebCore::FloatRect&); 154 156 void platformSetForcedAppearance(WebCore::InspectorFrontendClient::Appearance); -
trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in
r274815 r292084 30 30 Save(String filename, String content, bool base64Encoded, bool forceSaveAs) 31 31 Append(String filename, String content) 32 Load(String path) -> (String content) 32 33 33 34 SetForcedAppearance(WebCore::InspectorFrontendClient::Appearance appearance) -
trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.cpp
r290575 r292084 730 730 } 731 731 732 void WebInspectorUIProxy::load(const String& path, CompletionHandler<void(const String&)>&& completionHandler) 733 { 734 if (!m_inspectedPage->preferences().developerExtrasEnabled()) 735 return; 736 737 ASSERT(!path.isEmpty()); 738 if (path.isEmpty()) 739 return; 740 741 platformLoad(path, WTFMove(completionHandler)); 742 } 743 732 744 bool WebInspectorUIProxy::shouldOpenAttached() 733 745 { … … 824 836 } 825 837 838 void WebInspectorUIProxy::platformLoad(const String& path, CompletionHandler<void(const String&)>&& completionHandler) 839 { 840 notImplemented(); 841 completionHandler(nullString()); 842 } 843 826 844 unsigned WebInspectorUIProxy::platformInspectedWindowHeight() 827 845 { -
trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.h
r289875 r292084 237 237 void platformSave(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs); 238 238 void platformAppend(const String& filename, const String& content); 239 void platformLoad(const String& path, CompletionHandler<void(const String&)>&&); 239 240 240 241 #if PLATFORM(MAC) … … 263 264 void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs); 264 265 void append(const String& filename, const String& content); 266 void load(const String& path, CompletionHandler<void(const String&)>&&); 265 267 266 268 bool canAttach() const { return m_canAttach; } -
trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.messages.in
r278253 r292084 45 45 Save(String filename, String content, bool base64Encoded, bool forceSaveAs) 46 46 Append(String filename, String content) 47 Load(String path) -> (String content) 47 48 48 49 AttachBottom() -
trunk/Source/WebKit/UIProcess/Inspector/glib/RemoteInspectorClient.cpp
r291152 r292084 61 61 } 62 62 63 void load(Inspector::DebuggableType debuggableType)63 void initialize(Inspector::DebuggableType debuggableType) 64 64 { 65 65 m_proxy = RemoteWebInspectorUIProxy::create(); … … 68 68 Ref<API::DebuggableInfo> debuggableInfo = API::DebuggableInfo::create(DebuggableInfoData::empty()); 69 69 debuggableInfo->setDebuggableType(debuggableType); 70 m_proxy-> load(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL());70 m_proxy->initialize(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL()); 71 71 } 72 72 … … 244 244 m_socketConnection->sendMessage("Setup", g_variant_new("(tt)", connectionID, targetID)); 245 245 if (inspectorType == InspectorType::UI) 246 addResult.iterator->value-> load(debuggableType(targetType));246 addResult.iterator->value->initialize(debuggableType(targetType)); 247 247 } 248 248 -
trunk/Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp
r290394 r292084 163 163 } 164 164 165 void RemoteWebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler) 166 { 167 completionHandler(nullString()); 168 } 169 165 170 void RemoteWebInspectorUIProxy::platformSetSheetRect(const FloatRect&) 166 171 { -
trunk/Source/WebKit/UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp
r291835 r292084 563 563 } 564 564 565 void WebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler) 566 { 567 notImplemented(); 568 completionHandler(nullString()); 569 } 570 565 571 void WebInspectorUIProxy::platformAttachAvailabilityChanged(bool available) 566 572 { -
trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm
r277740 r292084 234 234 } 235 235 236 void RemoteWebInspectorUIProxy::platformLoad(const String& path, CompletionHandler<void(const String&)>&& completionHandler) 237 { 238 if (auto contents = FileSystem::readEntireFile(path)) 239 completionHandler(String::adopt(WTFMove(*contents))); 240 else 241 completionHandler(nullString()); 242 } 243 236 244 void RemoteWebInspectorUIProxy::platformSetSheetRect(const FloatRect& rect) 237 245 { -
trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm
r289875 r292084 578 578 } 579 579 580 void WebInspectorUIProxy::platformLoad(const String& path, CompletionHandler<void(const String&)>&& completionHandler) 581 { 582 if (auto contents = FileSystem::readEntireFile(path)) 583 completionHandler(String::adopt(WTFMove(*contents))); 584 else 585 completionHandler(nullString()); 586 } 587 580 588 void WebInspectorUIProxy::windowFrameDidChange() 581 589 { -
trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp
r278619 r292084 56 56 } 57 57 58 void load()58 void initialize() 59 59 { 60 60 // FIXME <https://webkit.org/b/205537>: this should infer more useful data about the debug target. 61 61 Ref<API::DebuggableInfo> debuggableInfo = API::DebuggableInfo::create(DebuggableInfoData::empty()); 62 62 debuggableInfo->setDebuggableType(m_debuggableType); 63 m_proxy-> load(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL());63 m_proxy->initialize(WTFMove(debuggableInfo), m_inspectorClient.backendCommandsURL()); 64 64 } 65 65 … … 178 178 sendWebInspectorEvent(setupEvent->toJSONString()); 179 179 180 addResult.iterator->value-> load();180 addResult.iterator->value->initialize(); 181 181 } 182 182 -
trunk/Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp
r274815 r292084 135 135 void RemoteWebInspectorUIProxy::platformSave(const String&, const String&, bool, bool) { } 136 136 void RemoteWebInspectorUIProxy::platformAppend(const String&, const String&) { } 137 void RemoteWebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler) { completionHandler(nullString()); } 137 138 void RemoteWebInspectorUIProxy::platformSetSheetRect(const WebCore::FloatRect&) { } 138 139 void RemoteWebInspectorUIProxy::platformSetForcedAppearance(WebCore::InspectorFrontendClient::Appearance) { } -
trunk/Source/WebKit/UIProcess/Inspector/win/WebInspectorUIProxyWin.cpp
r282889 r292084 419 419 } 420 420 421 void WebInspectorUIProxy::platformLoad(const String&, CompletionHandler<void(const String&)>&& completionHandler) 422 { 423 notImplemented(); 424 completionHandler(nullString()); 425 } 426 421 427 void WebInspectorUIProxy::platformAttachAvailabilityChanged(bool /* available */) 422 428 { -
trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp
r288999 r292084 229 229 } 230 230 231 void RemoteWebInspectorUI::load(const String& path, CompletionHandler<void(const String&)>&& completionHandler) 232 { 233 WebProcess::singleton().parentProcessConnection()->sendWithAsyncReply(Messages::RemoteWebInspectorUIProxy::Load(path), WTFMove(completionHandler), m_page.identifier()); 234 } 235 231 236 void RemoteWebInspectorUI::inspectedURLChanged(const String& urlString) 232 237 { -
trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h
r288999 r292084 108 108 void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs) override; 109 109 void append(const String& url, const String& content) override; 110 void load(const String& path, CompletionHandler<void(const String&)>&&) override; 110 111 void inspectedURLChanged(const String&) override; 111 112 void showCertificate(const WebCore::CertificateInfo&) override; … … 129 130 130 131 bool canSave() override { return true; } 132 bool canLoad() override { return true; } 131 133 bool isUnderTest() override { return false; } 132 134 unsigned inspectionLevel() const override { return 1; } -
trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp
r288999 r292084 328 328 } 329 329 330 void WebInspectorUI::load(const WTF::String& path, CompletionHandler<void(const String&)>&& completionHandler) 331 { 332 WebProcess::singleton().parentProcessConnection()->sendWithAsyncReply(Messages::WebInspectorUIProxy::Load(path), WTFMove(completionHandler), m_inspectedPageIdentifier); 333 } 334 330 335 void WebInspectorUI::inspectedURLChanged(const String& urlString) 331 336 { … … 496 501 } 497 502 503 bool WebInspectorUI::canLoad() 504 { 505 notImplemented(); 506 return false; 507 } 508 498 509 String WebInspectorUI::localizedStringsURL() const 499 510 { -
trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h
r288999 r292084 144 144 void save(const WTF::String& url, const WTF::String& content, bool base64Encoded, bool forceSaveAs) override; 145 145 void append(const WTF::String& url, const WTF::String& content) override; 146 bool canLoad() override; 147 void load(const WTF::String& path, WTF::CompletionHandler<void(const WTF::String&)>&&) override; 146 148 147 149 void inspectedURLChanged(const String&) override; -
trunk/Source/WebKit/WebProcess/Inspector/gtk/WebInspectorUIGtk.cpp
r255214 r292084 40 40 } 41 41 42 bool WebInspectorUI::canLoad() 43 { 44 return false; 45 } 46 42 47 String WebInspectorUI::localizedStringsURL() const 43 48 { -
trunk/Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm
r274697 r292084 38 38 } 39 39 40 bool WebInspectorUI::canLoad() 41 { 42 return true; 43 } 44 40 45 static String webInspectorUILocalizedStringsURL() 41 46 { -
trunk/Source/WebKit/WebProcess/Inspector/win/WebInspectorUIWin.cpp
r274912 r292084 40 40 } 41 41 42 bool WebInspectorUI::canLoad() 43 { 44 return false; 45 } 46 42 47 String WebInspectorUI::localizedStringsURL() const 43 48 {
Note: See TracChangeset
for help on using the changeset viewer.