Diff
Modified: trunk/Tools/ChangeLog (283837 => 283838)
--- trunk/Tools/ChangeLog 2021-10-08 21:03:32 UTC (rev 283837)
+++ trunk/Tools/ChangeLog 2021-10-08 21:12:11 UTC (rev 283838)
@@ -1,3 +1,31 @@
+2021-10-08 Fujii Hironori <[email protected]>
+
+ [Win][MiniBrowser][WK2] Implement Show Layer Tree to dump the GraphicsLayer tree
+ https://bugs.webkit.org/show_bug.cgi?id=231409
+
+ Reviewed by Don Olmstead.
+
+ MiniBrower has Show Layer Tree to dump the GraphicsLayer tree.
+ It's useful, but worked only in WebKit1. It should work for
+ WebKit2.
+
+ The layer tree are dumped to the debug console of WebProcess by
+ using OutputDebugString. You need to attach a debugger to it to
+ see the message. I'd like to recommend to install Child Process
+ Debugging Power Tool to your Visual Studio.
+
+ * MiniBrowser/win/CMakeLists.txt:
+ * MiniBrowser/win/Common2.cpp: Added.
+ (createString):
+ * MiniBrowser/win/Common2.h: Added.
+ * MiniBrowser/win/InjectedBundle.cpp: Added.
+ (didReceiveMessageToPage):
+ (WKBundleInitialize):
+ * MiniBrowser/win/WebKitBrowserWindow.cpp:
+ (injectedBundlePath):
+ (WebKitBrowserWindow::create):
+ (WebKitBrowserWindow::showLayerTree):
+
2021-10-08 Jonathan Bedard <[email protected]>
[contributors.json] Support GitHub usernames
Modified: trunk/Tools/MiniBrowser/win/CMakeLists.txt (283837 => 283838)
--- trunk/Tools/MiniBrowser/win/CMakeLists.txt 2021-10-08 21:03:32 UTC (rev 283837)
+++ trunk/Tools/MiniBrowser/win/CMakeLists.txt 2021-10-08 21:12:11 UTC (rev 283838)
@@ -48,11 +48,19 @@
if (ENABLE_WEBKIT)
list(APPEND MiniBrowser_PRIVATE_DEFINITIONS ENABLE_WEBKIT)
list(APPEND MiniBrowser_SOURCES
+ Common2.cpp
WebKitBrowserWindow.cpp
)
list(APPEND MiniBrowser_PRIVATE_LIBRARIES
WebKit::WebKit
)
+
+ add_library(MiniBrowserInjectedBundle SHARED
+ Common2.cpp
+ InjectedBundle.cpp
+ )
+ target_link_libraries(MiniBrowserInjectedBundle WebKit::WebKit)
+ target_include_directories(MiniBrowserInjectedBundle PRIVATE ${CMAKE_BINARY_DIR})
endif ()
WEBKIT_EXECUTABLE_DECLARE(MiniBrowser)
Added: trunk/Tools/MiniBrowser/win/Common2.cpp (0 => 283838)
--- trunk/Tools/MiniBrowser/win/Common2.cpp (rev 0)
+++ trunk/Tools/MiniBrowser/win/Common2.cpp 2021-10-08 21:12:11 UTC (rev 283838)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "stdafx.h"
+#include "Common2.h"
+
+#include <vector>
+
+std::wstring createString(WKStringRef wkString)
+{
+ size_t maxSize = WKStringGetLength(wkString);
+
+ std::vector<WKChar> wkCharBuffer(maxSize);
+ size_t actualLength = WKStringGetCharacters(wkString, wkCharBuffer.data(), maxSize);
+ return std::wstring(wkCharBuffer.data(), actualLength);
+}
Added: trunk/Tools/MiniBrowser/win/Common2.h (0 => 283838)
--- trunk/Tools/MiniBrowser/win/Common2.h (rev 0)
+++ trunk/Tools/MiniBrowser/win/Common2.h 2021-10-08 21:12:11 UTC (rev 283838)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2021 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <WebKit/WKRetainPtr.h>
+#include <WebKit/WKString.h>
+
+std::wstring createString(WKStringRef);
Added: trunk/Tools/MiniBrowser/win/InjectedBundle.cpp (0 => 283838)
--- trunk/Tools/MiniBrowser/win/InjectedBundle.cpp (rev 0)
+++ trunk/Tools/MiniBrowser/win/InjectedBundle.cpp 2021-10-08 21:12:11 UTC (rev 283838)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "stdafx.h"
+
+#include "Common2.h"
+#include <WebKit/WKBundle.h>
+#include <WebKit/WKBundleFramePrivate.h>
+#include <WebKit/WKBundlePage.h>
+#include <WebKit/WKBundlePrivate.h>
+
+void didReceiveMessageToPage(WKBundleRef bundle, WKBundlePageRef page, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo)
+{
+ if (WKStringIsEqualToUTF8CString(messageName, "DumpLayerTree")) {
+ auto frame = WKBundlePageGetMainFrame(page);
+ auto text = adoptWK(WKBundleFrameCopyLayerTreeAsText(frame));
+ OutputDebugString(createString(text.get()).c_str());
+ }
+}
+
+extern "C" __declspec(dllexport)
+void WKBundleInitialize(WKBundleRef bundle, WKTypeRef)
+{
+ WKBundleClientV1 client = {
+ { 1, nullptr },
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ didReceiveMessageToPage
+ };
+ WKBundleSetClient(bundle, &client.base);
+}
Modified: trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp (283837 => 283838)
--- trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp 2021-10-08 21:03:32 UTC (rev 283837)
+++ trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp 2021-10-08 21:12:11 UTC (rev 283838)
@@ -25,12 +25,14 @@
#include "stdafx.h"
#include "WebKitBrowserWindow.h"
+#include "Common.h"
+#include "Common2.h"
#include "MiniBrowserLibResource.h"
-#include "common.h"
#include <WebCore/GDIUtilities.h>
#include <WebKit/WKAuthenticationChallenge.h>
#include <WebKit/WKAuthenticationDecisionListener.h>
#include <WebKit/WKCertificateInfoCurl.h>
+#include <WebKit/WKContextConfigurationRef.h>
#include <WebKit/WKCredential.h>
#include <WebKit/WKInspector.h>
#include <WebKit/WKPreferencesRefPrivate.h>
@@ -38,17 +40,9 @@
#include <WebKit/WKProtectionSpaceCurl.h>
#include <WebKit/WKWebsiteDataStoreRef.h>
#include <WebKit/WKWebsiteDataStoreRefCurl.h>
+#include <filesystem>
#include <vector>
-std::wstring createString(WKStringRef wkString)
-{
- size_t maxSize = WKStringGetLength(wkString);
-
- std::vector<WKChar> wkCharBuffer(maxSize);
- size_t actualLength = WKStringGetCharacters(wkString, wkCharBuffer.data(), maxSize);
- return std::wstring(wkCharBuffer.data(), actualLength);
-}
-
std::wstring createString(WKURLRef wkURL)
{
if (!wkURL)
@@ -107,6 +101,22 @@
return adoptWK(WKURLCreateWithUTF8CString(utf8.data()));
}
+WKRetainPtr<WKStringRef> injectedBundlePath()
+{
+ auto module = GetModuleHandle(nullptr);
+ std::wstring path;
+ for (;;) {
+ path.resize(path.size() + MAX_PATH);
+ auto copied = GetModuleFileName(module, path.data(), path.size());
+ if (copied < path.size()) {
+ path.resize(copied);
+ break;
+ }
+ }
+ path = std::filesystem::path(path).replace_filename("MiniBrowserInjectedBundle.dll");
+ return createWKString(path);
+}
+
Ref<BrowserWindow> WebKitBrowserWindow::create(BrowserWindowClient& client, HWND mainWnd, bool)
{
auto conf = adoptWK(WKPageConfigurationCreate());
@@ -121,7 +131,10 @@
WKPreferencesSetDeveloperExtrasEnabled(prefs.get(), true);
WKPageConfigurationSetPreferences(conf.get(), prefs.get());
- auto context =adoptWK(WKContextCreateWithConfiguration(nullptr));
+ auto contextConf = adoptWK(WKContextConfigurationCreate());
+ WKContextConfigurationSetInjectedBundlePath(contextConf.get(), injectedBundlePath().get());
+
+ auto context = adoptWK(WKContextCreateWithConfiguration(contextConf.get()));
WKPageConfigurationSetContext(conf.get(), context.get());
return adoptRef(*new WebKitBrowserWindow(client, conf.get(), mainWnd));
@@ -280,7 +293,9 @@
void WebKitBrowserWindow::showLayerTree()
{
- // Not implemented
+ auto page = WKViewGetPage(m_view.get());
+ auto name = createWKString("DumpLayerTree");
+ WKPagePostMessageToInjectedBundle(page, name.get(), nullptr);
}
void WebKitBrowserWindow::updateStatistics(HWND hDlg)