Skip to content

Commit

Permalink
Remove WKBundleInspector object
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267462
rdar://120915383

Reviewed by Ryosuke Niwa.

WebKit::WebInspector is both an API::Object and an IPC::Connection::Client,
which is preventing a change I want to make to IPC::Connection::Client.
It turns out WKBundleInspector is only used in WebKitTestRunner for 3 test-only
functions.  Make WKBundlePage SPI for these functions instead.

* Source/WebKit/Modules/OSX_Private.modulemap:
* Source/WebKit/Modules/iOS_Private.modulemap:
* Source/WebKit/Shared/API/APIObject.h:
* Source/WebKit/Shared/API/c/WKBase.h:
* Source/WebKit/Sources.txt:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp: Removed.
* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleInspector.h: Removed.
* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageShowInspectorForTest):
(WKBundlePageCloseInspectorForTest):
(WKBundlePageEvaluateScriptInInspectorForTest):
(WKBundlePageGetInspector): Deleted.
* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* Source/WebKit/WebProcess/Inspector/WebInspector.cpp:
(WebKit::WebInspector::create):
(WebKit::WebInspector::WebInspector):
* Source/WebKit/WebProcess/Inspector/WebInspector.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::inspector):
* Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::showWebInspector):
(WTR::TestRunner::closeWebInspector):
(WTR::TestRunner::evaluateInWebInspector):

Canonical link: https://commits.webkit.org/272995@main
  • Loading branch information
achristensen07 committed Jan 12, 2024
1 parent 6e586d4 commit 66b2061
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 149 deletions.
1 change: 0 additions & 1 deletion Source/WebKit/Headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ set(WebKit_PUBLIC_FRAMEWORK_HEADERS
WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h
WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h
WebProcess/InjectedBundle/API/c/WKBundleInitialize.h
WebProcess/InjectedBundle/API/c/WKBundleInspector.h
WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h
WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h
WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h
Expand Down
5 changes: 0 additions & 5 deletions Source/WebKit/Modules/OSX_Private.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,6 @@ framework module WebKit_Private [system] {
export *
}

explicit module WKBundleInspector {
header "WKBundleInspector.h"
export *
}

explicit module WKBundleMac {
header "WKBundleMac.h"
export *
Expand Down
5 changes: 0 additions & 5 deletions Source/WebKit/Modules/iOS_Private.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,6 @@ framework module WebKit_Private [system] {
export *
}

explicit module WKBundleInspector {
header "WKBundleInspector.h"
export *
}

explicit module WKBundleMac {
header "WKBundleMac.h"
export *
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/Shared/API/APIObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ class Object
BundleDOMWindowExtension,
BundleFrame,
BundleHitTestResult,
BundleInspector,
BundleNodeHandle,
BundlePage,
BundlePageBanner,
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/Shared/API/c/WKBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ typedef const struct OpaqueWKBundleDOMWindowExtension* WKBundleDOMWindowExtensio
typedef const struct OpaqueWKBundleFileHandle* WKBundleFileHandleRef;
typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
typedef const struct OpaqueWKBundleNavigationAction* WKBundleNavigationActionRef;
typedef const struct OpaqueWKBundleNodeHandle* WKBundleNodeHandleRef;
typedef const struct OpaqueWKBundlePage* WKBundlePageRef;
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/Shared/API/c/wpe/WebKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#include <WebKit/WKBundleFrame.h>
#include <WebKit/WKBundleHitTestResult.h>
#include <WebKit/WKBundleInitialize.h>
#include <WebKit/WKBundleInspector.h>
#include <WebKit/WKBundleNavigationAction.h>
#include <WebKit/WKBundleNodeHandle.h>
#include <WebKit/WKBundlePage.h>
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/Sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ WebProcess/InjectedBundle/API/c/WKBundleBackForwardListItem.cpp
WebProcess/InjectedBundle/API/c/WKBundleDOMWindowExtension.cpp
WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp
WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp
WebProcess/InjectedBundle/API/c/WKBundleInspector.cpp
WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp
WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp
WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Expand Down
10 changes: 4 additions & 6 deletions Source/WebKit/WebKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,6 @@
637281A321ADC744009E0DE6 /* WKDownloadProgress.mm in Sources */ = {isa = PBXBuildFile; fileRef = 637281A121ADC744009E0DE6 /* WKDownloadProgress.mm */; };
63C32C261E9810D900699BD0 /* _WKGeolocationPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 63C32C241E9810D900699BD0 /* _WKGeolocationPosition.h */; settings = {ATTRIBUTES = (Private, ); }; };
63C32C281E98119000699BD0 /* _WKGeolocationPositionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 63C32C271E98119000699BD0 /* _WKGeolocationPositionInternal.h */; };
65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
6A5080BF1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 6A5080BE1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
6BD05865220CE8C2000BED5C /* PrivateClickMeasurementManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BD05863220CE8C2000BED5C /* PrivateClickMeasurementManager.h */; };
6BE969C11E54D452008B7483 /* corePrediction_model in Resources */ = {isa = PBXBuildFile; fileRef = 6BE969C01E54D452008B7483 /* corePrediction_model */; };
Expand Down Expand Up @@ -6049,8 +6048,6 @@
63FABE191E970D65003011D5 /* _WKGeolocationCoreLocationProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKGeolocationCoreLocationProvider.h; sourceTree = "<group>"; };
6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageResourceLoadClient.cpp; sourceTree = "<group>"; };
6546A82A13000164000CEB1C /* InjectedBundlePageResourceLoadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageResourceLoadClient.h; sourceTree = "<group>"; };
65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = "<group>"; };
65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInspector.h; sourceTree = "<group>"; };
6A5080BE1F0EDAAA00E617C5 /* WKWindowFeaturesPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWindowFeaturesPrivate.h; sourceTree = "<group>"; };
6BD05863220CE8C2000BED5C /* PrivateClickMeasurementManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementManager.h; sourceTree = "<group>"; };
6BD05864220CE8C2000BED5C /* PrivateClickMeasurementManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementManager.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -13798,8 +13795,6 @@
BC49862E124D18C100D834E1 /* WKBundleHitTestResult.cpp */,
BC49862D124D18C100D834E1 /* WKBundleHitTestResult.h */,
BC204EED11C83EC8008F3375 /* WKBundleInitialize.h */,
65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */,
65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */,
BC7043CB12F75EE0006472B9 /* WKBundleNavigationAction.cpp */,
BC7043CA12F75EE0006472B9 /* WKBundleNavigationAction.h */,
51A728DC1B1BAD2D00102EEE /* WKBundleNavigationActionPrivate.h */,
Expand Down Expand Up @@ -16328,7 +16323,6 @@
BCF049E611FE20F600F86A58 /* WKBundleFramePrivate.h in Headers */,
BC49862F124D18C100D834E1 /* WKBundleHitTestResult.h in Headers */,
BC204EF211C83EC8008F3375 /* WKBundleInitialize.h in Headers */,
65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */,
1A8B66B41BC45B010082DF77 /* WKBundleMac.h in Headers */,
BC7043CC12F75EE0006472B9 /* WKBundleNavigationAction.h in Headers */,
51A728DE1B1BAD3800102EEE /* WKBundleNavigationActionPrivate.h in Headers */,
Expand Down Expand Up @@ -18947,6 +18941,7 @@
isa = PBXTargetDependency;
platformFilters = (
ios,
xros,
);
target = 5C139DA129DB82E500D5117B /* WebContentCaptivePortalExtension */;
targetProxy = 5C400E6929DB8AB500446F6F /* PBXContainerItemProxy */;
Expand All @@ -18965,6 +18960,7 @@
isa = PBXTargetDependency;
platformFilters = (
ios,
xros,
);
target = 5CA5A2C929CBBA1A000F1046 /* WebContentExtension */;
targetProxy = 5CE4B60629CEBB760038F565 /* PBXContainerItemProxy */;
Expand All @@ -18973,6 +18969,7 @@
isa = PBXTargetDependency;
platformFilters = (
ios,
xros,
);
target = 5CE4B61529CF877F0038F565 /* GPUExtension */;
targetProxy = 5CE4B62229CF880B0038F565 /* PBXContainerItemProxy */;
Expand All @@ -18981,6 +18978,7 @@
isa = PBXTargetDependency;
platformFilters = (
ios,
xros,
);
target = 5CE4B60829CF87680038F565 /* NetworkingExtension */;
targetProxy = 5CE4B62429CF880B0038F565 /* PBXContainerItemProxy */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, InjectedBundleCSSStyleDeclara
WK_ADD_API_MAPPING(WKBundleDOMWindowExtensionRef, InjectedBundleDOMWindowExtension)
WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector)
WK_ADD_API_MAPPING(WKBundleNodeHandleRef, InjectedBundleNodeHandle)
WK_ADD_API_MAPPING(WKBundlePageBannerRef, PageBanner)
WK_ADD_API_MAPPING(WKBundlePageOverlayRef, WebPageOverlay)
Expand Down

This file was deleted.

52 changes: 0 additions & 52 deletions Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleInspector.h

This file was deleted.

14 changes: 12 additions & 2 deletions Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,19 @@ void WKBundlePageListenForLayoutMilestones(WKBundlePageRef pageRef, WKLayoutMile
WebKit::toImpl(pageRef)->listenForLayoutMilestones(WebKit::toLayoutMilestones(milestones));
}

WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef pageRef)
void WKBundlePageShowInspectorForTest(WKBundlePageRef page)
{
return WebKit::toAPI(WebKit::toImpl(pageRef)->inspector());
WebKit::toImpl(page)->inspector()->show();
}

void WKBundlePageCloseInspectorForTest(WKBundlePageRef page)
{
WebKit::toImpl(page)->inspector()->close();
}

void WKBundlePageEvaluateScriptInInspectorForTest(WKBundlePageRef page, WKStringRef script)
{
WebKit::toImpl(page)->inspector()->evaluateScriptForTest(WebKit::toWTFString(script));
}

void WKBundlePageForceRepaint(WKBundlePageRef page)
Expand Down
4 changes: 3 additions & 1 deletion Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ WK_EXPORT double WKBundlePageGetBackingScaleFactor(WKBundlePageRef page);

WK_EXPORT void WKBundlePageListenForLayoutMilestones(WKBundlePageRef page, WKLayoutMilestones milestones);

WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page);
WK_EXPORT void WKBundlePageShowInspectorForTest(WKBundlePageRef page);
WK_EXPORT void WKBundlePageCloseInspectorForTest(WKBundlePageRef page);
WK_EXPORT void WKBundlePageEvaluateScriptInInspectorForTest(WKBundlePageRef page, WKStringRef script);

WK_EXPORT bool WKBundlePageIsUsingEphemeralSession(WKBundlePageRef page);

Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/WebProcess/Inspector/WebInspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ static const float minimumAttachedWidth = 500;
namespace WebKit {
using namespace WebCore;

Ref<WebInspector> WebInspector::create(WebPage* page)
Ref<WebInspector> WebInspector::create(WebPage& page)
{
return adoptRef(*new WebInspector(page));
}

WebInspector::WebInspector(WebPage* page)
WebInspector::WebInspector(WebPage& page)
: m_page(page)
{
}
Expand Down
10 changes: 5 additions & 5 deletions Source/WebKit/WebProcess/Inspector/WebInspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@

#pragma once

#include "APIObject.h"
#include "Connection.h"
#include "MessageReceiver.h"
#include <WebCore/FrameIdentifier.h>
#include <WebCore/InspectorClient.h>
#include <wtf/Noncopyable.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/text/WTFString.h>

namespace WebKit {

class WebPage;

class WebInspector : public API::ObjectImpl<API::Object::Type::BundleInspector>, private IPC::Connection::Client {
class WebInspector : public ThreadSafeRefCounted<WebInspector>, private IPC::Connection::Client {
public:
static Ref<WebInspector> create(WebPage*);
static Ref<WebInspector> create(WebPage&);
~WebInspector();

WebPage* page() const;

Expand Down Expand Up @@ -86,8 +87,7 @@ class WebInspector : public API::ObjectImpl<API::Object::Type::BundleInspector>,
private:
friend class WebInspectorClient;

explicit WebInspector(WebPage*);
virtual ~WebInspector();
explicit WebInspector(WebPage&);

bool canAttachWindow();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class UnifiedPDFPlugin final : public PDFPluginBase, public WebCore::GraphicsLay

// ScrollableArea
bool requestScrollToPosition(const WebCore::ScrollPosition&, const WebCore::ScrollPositionChangeOptions& = WebCore::ScrollPositionChangeOptions::createProgrammatic()) override;
bool requestStartKeyboardScrollAnimation(const KeyboardScroll& scrollData) override;
bool requestStartKeyboardScrollAnimation(const WebCore::KeyboardScroll& scrollData) override;
bool requestStopKeyboardScrollAnimation(bool immediate) override;

// HUD Actions.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/WebPage/WebPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4907,7 +4907,7 @@ WebInspector* WebPage::inspector(LazyCreationPolicy behavior)
if (m_isClosed)
return nullptr;
if (!m_inspector && behavior == LazyCreationPolicy::CreateIfNeeded)
m_inspector = WebInspector::create(this);
m_inspector = WebInspector::create(*this);
return m_inspector.get();
}

Expand Down
7 changes: 3 additions & 4 deletions Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include <WebKit/WKBundleBackForwardList.h>
#include <WebKit/WKBundleFrame.h>
#include <WebKit/WKBundleFramePrivate.h>
#include <WebKit/WKBundleInspector.h>
#include <WebKit/WKBundleNodeHandlePrivate.h>
#include <WebKit/WKBundlePage.h>
#include <WebKit/WKBundlePagePrivate.h>
Expand Down Expand Up @@ -541,17 +540,17 @@ void TestRunner::makeWindowObject(JSContextRef context)

void TestRunner::showWebInspector()
{
WKBundleInspectorShow(WKBundlePageGetInspector(page()));
WKBundlePageShowInspectorForTest(page());
}

void TestRunner::closeWebInspector()
{
WKBundleInspectorClose(WKBundlePageGetInspector(page()));
WKBundlePageCloseInspectorForTest(page());
}

void TestRunner::evaluateInWebInspector(JSStringRef script)
{
WKBundleInspectorEvaluateScriptForTest(WKBundlePageGetInspector(page()), toWK(script).get());
WKBundlePageEvaluateScriptInInspectorForTest(page(), toWK(script).get());
}

using WorldMap = WTF::HashMap<unsigned, WKRetainPtr<WKBundleScriptWorldRef>>;
Expand Down

0 comments on commit 66b2061

Please sign in to comment.