Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Web Inspector: replace the two "Export Audit" and "Export Result" but…
…tons with a single button that has a picker in the `NSSavePanel` https://bugs.webkit.org/show_bug.cgi?id=241214 <rdar://problem/76775840> Reviewed by Patrick Angle. It's odd to have only one "Import" button but two "Export *" buttons in the Audits Tab, Graphics Tab, etc. Ideally, there'd be just one "Export" button that lets the developer choose what kind of data to save (i.e. all formats are provided up front, and the developer picks what's actually used). * Source/WebInspectorUI/UserInterface/Base/FileUtilities.js: (WI.FileUtilities.canSave): Added. (WI.FileUtilities.async save): Added. (WI.FileUtilities.save): Deleted. * Source/WebCore/inspector/InspectorFrontendHost.idl: * Source/WebCore/inspector/InspectorFrontendHost.h: * Source/WebCore/inspector/InspectorFrontendHost.cpp: (WebCore::InspectorFrontendHost::canSave): (WebCore::InspectorFrontendHost::save): Introduce a new `SaveMode` that's used to both check for multi-format saving support and indicate that a particular save operation has multiple formats. Always require an array of `SaveData` to be provided when saving, but only expect a single item when the save operation is not multi-format. * Source/WebInspectorUI/UserInterface/Base/Main.js: (WI._contextMenuRequested): (WI._updateDownloadTabBarButton): (WI._save): (WI._saveAs): (WI.archiveMainFrame): (WI.canArchiveMainFrame): * Source/WebInspectorUI/UserInterface/Controllers/AuditManager.js: (WI.AuditManager.prototype.export): (WI.AuditManager.prototype.export.dataForObject): Added. * Source/WebInspectorUI/UserInterface/Debug/ProtocolTrace.js: (WI.ProtocolTrace.prototype.get saveMode): Added. * Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js: (WI.TimelineRecording.prototype.get exportMode): Added. (WI.TimelineRecording.prototype.canExport): * Source/WebInspectorUI/UserInterface/Views/AuditTestContentView.js: (WI.AuditTestContentView): (WI.AuditTestContentView.prototype.get navigationItems): (WI.AuditTestContentView.prototype.get supportsSave): (WI.AuditTestContentView.prototype.get saveMode): Added. (WI.AuditTestContentView.prototype.get saveData): (WI.AuditTestContentView.prototype._export): Added. (WI.AuditTestContentView.prototype._updateExportNavigationItems): (WI.AuditTestContentView.prototype._handleExportTestButtonNavigationItemClicked): (WI.AuditTestContentView.prototype._handleExportResultButtonNavigationItemClicked): (WI.AuditTestContentView.prototype._handleExportButtonNavigationItemClicked): Added. (WI.AuditTestContentView.prototype._exportResult): Deleted. * Source/WebInspectorUI/UserInterface/Views/AuditTreeElement.js: (WI.AuditTreeElement.prototype.populateContextMenu): * Source/WebInspectorUI/UserInterface/Views/ClusterContentView.js: (WI.ClusterContentView.prototype.get supportsSave): (WI.ClusterContentView.prototype.get saveMode): Added. (WI.ClusterContentView.prototype.get saveData): * Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js: (WI.ConsoleMessageView.prototype._handleContextMenu): * Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js: (WI.appendContextMenuItemsForSourceCode): * Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js: (WI.DOMTreeContentView.prototype.get saveMode): Added. * Source/WebInspectorUI/UserInterface/Views/HeapSnapshotContentView.js: (WI.HeapSnapshotContentView): (WI.HeapSnapshotContentView.prototype._exportSnapshot): * Source/WebInspectorUI/UserInterface/Views/LogContentView.js: (WI.LogContentView.prototype.get saveMode): Added. (WI.LogContentView.prototype._handleContextMenuEvent): * Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js: (WI.NetworkTableContentView): (WI.NetworkTableContentView.prototype.get saveMode): Added. (WI.NetworkTableContentView.prototype._canExportHAR): (WI.NetworkTableContentView.prototype._exportHAR): * Source/WebInspectorUI/UserInterface/Views/RecordingContentView.js: (WI.RecordingContentView): (WI.RecordingContentView.prototype.get supportsSave): (WI.RecordingContentView.prototype.get saveMode): Added. (WI.RecordingContentView.prototype.get saveData): (WI.RecordingContentView.prototype._export): Added. (WI.RecordingContentView.prototype._exportRecording): (WI.RecordingContentView.prototype._exportReduction): (WI.RecordingContentView.prototype._updateExportButton): (WI.RecordingContentView.prototype._handleExportNavigationItemClicked): * Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js: (WI.ResourceContentView.prototype.get saveMode): Added. * Source/WebInspectorUI/UserInterface/Views/ScriptContentView.js: (WI.ScriptContentView.prototype.get saveMode): Added. * Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.js: (WI.ShaderProgramContentView): (WI.ShaderProgramContentView.prototype.get supportsSave): (WI.ShaderProgramContentView.prototype.get saveMode): Added. (WI.ShaderProgramContentView.prototype.get saveData): * Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js: (WI.SpreadsheetCSSStyleDeclarationSection.prototype.initialLayout): (WI.SpreadsheetCSSStyleDeclarationSection.prototype._save): * Source/WebInspectorUI/UserInterface/Views/TextContentView.js: (WI.TextContentView.prototype.get saveMode): * Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js: (WI.TextResourceContentView.prototype.get saveData): * Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js: (WI.TimelineRecordingContentView.prototype.get saveMode): (WI.TimelineRecordingContentView.prototype._exportTimelineRecording): Indicate the kind of `SaveMode` that's used. When multi-format is supported, use it to unify the export buttons (if applicable). Also make sure to only enable the export button(s) if the desired `SaveMode` is supported. * Source/WebKit/WebProcess/Inspector/WebInspectorUI.h: * Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp: (WebKit::WebInspectorUI::save): (WebKit::WebInspectorUI::canSave): * Source/WebKit/WebProcess/Inspector/gtk/WebInspectorUIGtk.cpp: (WebKit::WebInspectorUI::canSave): (WebKit::RemoteWebInspectorUI::localizedStringsURL const): Deleted. * Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm: (WebKit::WebInspectorUI::canSave): (WebKit::WebInspectorUI::localizedStringsURL const): (WebKit::webInspectorUILocalizedStringsURL): Deleted. (WebKit::RemoteWebInspectorUI::localizedStringsURL const): Deleted. * Source/WebKit/WebProcess/Inspector/win/WebInspectorUIWin.cpp: (WebKit::WebInspectorUI::canSave): (WebKit::RemoteWebInspectorUI::localizedStringsURL const): Deleted. * Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h: * Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp: (WebKit::RemoteWebInspectorUI::save): (WebKit::RemoteWebInspectorUI::canSave): Added. (WebKit::RemoteWebInspectorUI::canLoad): Added. * Source/WebKit/WebProcess/Inspector/gtk/RemoteWebInspectorUIGtk.cpp: Added. (WebKit::RemoteWebInspectorUI::canSave): (WebKit::RemoteWebInspectorUI::canLoad): (WebKit::RemoteWebInspectorUI::localizedStringsURL const): * Source/WebKit/WebProcess/Inspector/mac/RemoteWebInspectorUIMac.mm: Added. (WebKit::RemoteWebInspectorUI::canSave): (WebKit::RemoteWebInspectorUI::canLoad): (WebKit::RemoteWebInspectorUI::localizedStringsURL const): * Source/WebKit/WebProcess/Inspector/win/RemoteWebInspectorUIWin.cpp: Added. (WebKit::RemoteWebInspectorUI::canSave): (WebKit::RemoteWebInspectorUI::canLoad): (WebKit::RemoteWebInspectorUI::localizedStringsURL const): Currently, macOS supports both single and multi-format saving, GTK supports single format saving, and windows supports neither. Drive-by: Add `RemoteWebInspectorProxy*` files for each platform instead of shoving the code into the related `WebInspectorProxy*` (of the same platform). * Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.messages.in: * Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.h: * Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.cpp: (WebKit::WebInspectorUIProxy::save): (WebKit::WebInspectorUIProxy::platformSave): * Source/WebKit/UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp: (WebKit::WebInspectorUIProxy::platformSave): * Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm: (-[WKWebInspectorUISaveController initWithSaveDatas:savePanel:]): Added. (-[WKWebInspectorUISaveController content]): Added. (-[WKWebInspectorUISaveController base64Encoded]): Added. (-[WKWebInspectorUISaveController _updateSavePanel]): Added. (-[WKWebInspectorUISaveController _popUpButtonAction:]): Added. (WebKit::WebInspectorUIProxy::showSavePanel): (WebKit::WebInspectorUIProxy::platformSave): Added. * Source/WebKit/UIProcess/Inspector/win/WebInspectorUIProxyWin.cpp: (WebKit::WebInspectorUIProxy::platformSave): * Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in: * Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.h: * Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp: (WebKit::RemoteWebInspectorUIProxy::save): (WebKit::RemoteWebInspectorUIProxy::platformSave): * Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp: (WebKit::RemoteWebInspectorUIProxy::platformSave): * Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm: (WebKit::RemoteWebInspectorUIProxy::platformSave): * Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp: (WebKit::RemoteWebInspectorUIProxy::platformSave): On macOS, create a shared function to show a `NSSavePanel` with an `accessoryView` that lets the developer choose which format to save with. On GTK, there should only ever be a single `SaveData` provided (since GTK only supports single format saving), so use that. * Source/WebKitLegacy/mac/WebCoreSupport/WebInspectorClient.h: * Source/WebKitLegacy/mac/WebCoreSupport/WebInspectorClient.mm: (WebInspectorFrontendClient::canSave): (WebInspectorFrontendClient::save): * Source/WebKitLegacy/ios/WebCoreSupport/WebInspectorClientIOS.mm: (WebInspectorFrontendClient::save): WK1 only supports single format saving, meaning that there should only ever be a single `SaveData` provided, so use that. * Source/WebCore/inspector/InspectorFrontendClient.h: (WebCore::InspectorFrontendClient::SaveData::encode const): (WebCore::InspectorFrontendClient::SaveData::decode): IPC stuff. * Source/WebCore/inspector/InspectorFrontendClientLocal.h: (WebCore::InspectorFrontendClientLocal::canSave): (WebCore::InspectorFrontendClientLocal::save): Testing code doesn't (need to) know how to save things. * Source/WebInspectorUI/UserInterface/Base/URLUtilities.js: (WI.urlWithoutExtension): Added. * LayoutTests/inspector/unit-tests/url-utilities.html: * LayoutTests/inspector/unit-tests/url-utilities-expected.txt: Drive-by: Added a utility method to help in a `console.assert`. * Source/WebCore/en.lproj/Localizable.strings: * Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js: * Source/WebKit/PlatformWin.cmake: * Source/WebKit/SourcesCocoa.txt: * Source/WebKit/SourcesGTK.txt: * Source/WebKit/WebKit.xcodeproj/project.pbxproj: Canonical link: https://commits.webkit.org/251295@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information