2017-07-18 07:20:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Igalia S.L.
|
|
|
|
*
|
|
|
|
* 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. AND ITS CONTRIBUTORS ``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 ITS 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 "config.h"
|
|
|
|
#include "WebDriverService.h"
|
|
|
|
|
|
|
|
#include "Capabilities.h"
|
|
|
|
#include "CommandResult.h"
|
|
|
|
#include "SessionHost.h"
|
|
|
|
#include <wtf/RunLoop.h>
|
2021-05-10 16:57:02 +00:00
|
|
|
#include <wtf/text/StringToIntegerConversion.h>
|
2017-07-18 07:20:33 +00:00
|
|
|
#include <wtf/text/WTFString.h>
|
|
|
|
|
|
|
|
namespace WebDriver {
|
|
|
|
|
2018-01-26 09:50:58 +00:00
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-maximum-safe-integer
|
|
|
|
static const double maxSafeInteger = 9007199254740991.0; // 2 ^ 53 - 1
|
|
|
|
|
2017-07-18 07:20:33 +00:00
|
|
|
WebDriverService::WebDriverService()
|
|
|
|
: m_server(*this)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void printUsageStatement(const char* programName)
|
|
|
|
{
|
|
|
|
printf("Usage: %s options\n", programName);
|
2020-09-30 21:22:57 +00:00
|
|
|
printf(" -h, --help Prints this help message\n");
|
|
|
|
printf(" -p <port>, --port=<port> Port number the driver will use\n");
|
|
|
|
printf(" --host=<host> Host IP the driver will use, or either 'local' or 'all' (default: 'local')\n");
|
|
|
|
#if USE(INSPECTOR_SOCKET_SERVER)
|
|
|
|
printf(" -t <ip:port> --target=<ip:port> [WinCairo] Target IP and port\n");
|
|
|
|
#endif
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int WebDriverService::run(int argc, char** argv)
|
|
|
|
{
|
|
|
|
String portString;
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<String> host;
|
2020-09-30 21:22:57 +00:00
|
|
|
#if USE(INSPECTOR_SOCKET_SERVER)
|
|
|
|
String targetString;
|
|
|
|
if (const char* targetEnvVar = getenv("WEBDRIVER_TARGET_ADDR"))
|
|
|
|
targetString = targetEnvVar;
|
|
|
|
#endif
|
[CMake] Properly test if compiler supports compiler flags
https://bugs.webkit.org/show_bug.cgi?id=174490
Reviewed by Konstantin Tokarev.
.:
This turned out to be a massive pain. I didn't want to merely check options before using
them: I also wanted to organize the code to avoid setting similar flags in different places.
Right now we set a bunch of global flags in OptionsCommon.cmake, and a bunch more flags in
WEBKIT_SET_EXTRA_COMPILER_FLAGS on a per-target basis.
Setting flags per-target seems better in general, e.g. because it makes it very easy to
disable warnings for particular ThirdParty targets. But it turns out that all the flags set
on a per-target basis get passed to both the C compiler and the C++ compiler, so it's
impossible to pass C++-only flags there. That's terrible. It's possible to make the flags
language-conditional using generator expressions, but that doesn't work for the Visual
Studio backend, so we would have to drop support for that (not going to happen). The CMake
documentation suggests that C and C++ files ought to be built in separate targets to avoid
this. It's a mess, basically.
So I've wound up removing WEBKIT_SET_EXTRA_COMPILER_FLAGS and adding most of those flags to
CMAKE_C_FLAGS and CMAKE_CXX_FLAGS instead. Really the only disadvantage of this is we now
have to suppress individual warnings when building ANGLESupport in WebCore. That's not the
end of the world. The only remaining useful feature of WEBKIT_SET_EXTRA_COMPILER_FLAGS was
to add -fPIC to static library targets, but turns out CMake does that for us if we just set
the variable CMAKE_POSITION_INDEPENDENT_CODE, so we can get rid of it completely.
Of course there are also macros for setting target-specific compiler flags, which we
frequently need in order to suppress specific warnings, particularly warnings coming from
third-party libraries like ANGLE and gtest. But remember the footgun: these macros will test
the flag against only one compiler, but must work with both C and C++ compilers unless the
build target exclusively contains targets built with just one of those compilers. Yuck.
* CMakeLists.txt:
* Source/CMakeLists.txt:
* Source/PlatformGTK.cmake:
* Source/cmake/OptionsCommon.cmake:
* Source/cmake/WebKitCommon.cmake:
* Source/cmake/WebKitCompilerFlags.cmake: Added.
* Source/cmake/WebKitMacros.cmake:
Source/JavaScriptCore:
* API/tests/PingPongStackOverflowTest.cpp:
(testPingPongStackOverflow):
* API/tests/testapi.c:
* b3/testb3.cpp:
(JSC::B3::testPatchpointLotsOfLateAnys):
Source/ThirdParty:
* brotli/CMakeLists.txt:
* gtest/CMakeLists.txt:
* woff2/CMakeLists.txt:
* xdgmime/CMakeLists.txt:
Source/WebCore:
* CMakeLists.txt:
* PlatformGTK.cmake:
* PlatformWPE.cmake:
Source/WebDriver:
* WebDriverService.cpp:
(WebDriver::WebDriverService::run):
* glib/SessionHostGlib.cpp:
Source/WebKit:
* CMakeLists.txt:
* PlatformGTK.cmake:
Source/WTF:
* wtf/Compiler.h:
Tools:
* DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt:
* MiniBrowser/gtk/CMakeLists.txt:
* TestRunnerShared/Bindings/JSWrapper.cpp:
(WTR::JSWrapper::initialize):
* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:
(TestWebKitAPI::CheckedArithmeticTester::run):
* TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp:
* TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp:
* TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp:
(formControlsAssociatedCallback):
* TestWebKitAPI/glib/CMakeLists.txt:
* TestWebKitAPI/glib/WebKitGLib/TestMain.h:
(Test::getResourcesDir):
* WebKitTestRunner/CMakeLists.txt:
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::menuItemClickCallback):
(WTR::staticConvertMenuItemToType):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setUseDashboardCompatibilityMode):
* WebKitTestRunner/InjectedBundle/atk/AccessibilityNotificationHandlerAtk.cpp:
(WTR::AccessibilityNotificationHandler::disconnectAccessibilityCallbacks):
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::helpText const):
(WTR::AccessibilityUIElement::attributedStringForRange):
* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
(WTR::EventSenderProxy::updateTouchPoint):
(WTR::EventSenderProxy::releaseTouchPoint):
Canonical link: https://commits.webkit.org/192040@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-08 15:03:48 +00:00
|
|
|
for (int i = 1 ; i < argc; ++i) {
|
2017-07-18 07:20:33 +00:00
|
|
|
const char* arg = argv[i];
|
|
|
|
if (!strcmp(arg, "-h") || !strcmp(arg, "--help")) {
|
|
|
|
printUsageStatement(argv[0]);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(arg, "-p") && portString.isNull()) {
|
|
|
|
if (++i == argc) {
|
|
|
|
printUsageStatement(argv[0]);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
portString = argv[i];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const unsigned portStrLength = strlen("--port=");
|
|
|
|
if (!strncmp(arg, "--port=", portStrLength) && portString.isNull()) {
|
|
|
|
portString = String(arg + portStrLength);
|
|
|
|
continue;
|
|
|
|
}
|
2018-07-05 12:41:08 +00:00
|
|
|
|
|
|
|
static const unsigned hostStrLength = strlen("--host=");
|
|
|
|
if (!strncmp(arg, "--host=", hostStrLength) && !host) {
|
|
|
|
host = String(arg + hostStrLength);
|
|
|
|
continue;
|
|
|
|
}
|
2020-09-30 21:22:57 +00:00
|
|
|
|
|
|
|
#if USE(INSPECTOR_SOCKET_SERVER)
|
|
|
|
if (!strcmp(arg, "-t") && targetString.isNull()) {
|
|
|
|
if (++i == argc) {
|
|
|
|
printUsageStatement(argv[0]);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
targetString = argv[i];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const unsigned targetStrLength = strlen("--target=");
|
|
|
|
if (!strncmp(arg, "--target=", targetStrLength) && targetString.isNull()) {
|
|
|
|
targetString = String(arg + targetStrLength);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (portString.isNull()) {
|
|
|
|
printUsageStatement(argv[0]);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2020-09-30 21:22:57 +00:00
|
|
|
#if USE(INSPECTOR_SOCKET_SERVER)
|
|
|
|
if (!targetString.isEmpty()) {
|
|
|
|
auto position = targetString.reverseFind(":"_s);
|
|
|
|
if (position != notFound) {
|
|
|
|
m_targetAddress = targetString.left(position);
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
m_targetPort = parseIntegerAllowingTrailingJunk<uint16_t>(StringView { targetString }.substring(position + 1)).value_or(0);
|
2020-09-30 21:22:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-05-10 16:57:02 +00:00
|
|
|
auto port = parseInteger<uint16_t>(portString);
|
|
|
|
if (!port) {
|
|
|
|
fprintf(stderr, "Invalid port %s provided\n", portString.utf8().data());
|
2017-07-18 07:20:33 +00:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2020-06-26 19:28:18 +00:00
|
|
|
WTF::initializeMainThread();
|
2017-07-18 07:20:33 +00:00
|
|
|
|
2021-05-10 16:57:02 +00:00
|
|
|
if (!m_server.listen(host, *port))
|
2017-07-18 07:20:33 +00:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
RunLoop::run();
|
|
|
|
|
|
|
|
m_server.disconnect();
|
2017-08-16 11:38:22 +00:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const WebDriverService::Command WebDriverService::s_commands[] = {
|
|
|
|
{ HTTPMethod::Post, "/session", &WebDriverService::newSession },
|
|
|
|
{ HTTPMethod::Delete, "/session/$sessionId", &WebDriverService::deleteSession },
|
2017-12-01 09:49:10 +00:00
|
|
|
{ HTTPMethod::Get, "/status", &WebDriverService::status },
|
2018-01-11 10:00:31 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/timeouts", &WebDriverService::getTimeouts },
|
2017-07-18 07:20:33 +00:00
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/timeouts", &WebDriverService::setTimeouts },
|
|
|
|
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/url", &WebDriverService::go },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/url", &WebDriverService::getCurrentURL },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/back", &WebDriverService::back },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/forward", &WebDriverService::forward },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/refresh", &WebDriverService::refresh },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/title", &WebDriverService::getTitle },
|
|
|
|
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/window", &WebDriverService::getWindowHandle },
|
|
|
|
{ HTTPMethod::Delete, "/session/$sessionId/window", &WebDriverService::closeWindow },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/window", &WebDriverService::switchToWindow },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/window/handles", &WebDriverService::getWindowHandles },
|
2019-11-12 08:12:40 +00:00
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/window/new", &WebDriverService::newWindow },
|
2017-07-18 07:20:33 +00:00
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/frame", &WebDriverService::switchToFrame },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/frame/parent", &WebDriverService::switchToParentFrame },
|
2017-09-20 06:32:35 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/window/rect", &WebDriverService::getWindowRect },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/window/rect", &WebDriverService::setWindowRect },
|
2018-05-24 08:54:37 +00:00
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/window/maximize", &WebDriverService::maximizeWindow },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/window/minimize", &WebDriverService::minimizeWindow },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/window/fullscreen", &WebDriverService::fullscreenWindow },
|
2017-07-18 07:20:33 +00:00
|
|
|
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/element", &WebDriverService::findElement },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/elements", &WebDriverService::findElements },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/element/$elementId/element", &WebDriverService::findElementFromElement },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/element/$elementId/elements", &WebDriverService::findElementsFromElement },
|
2017-11-28 07:55:36 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/active", &WebDriverService::getActiveElement },
|
2017-07-18 07:20:33 +00:00
|
|
|
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/selected", &WebDriverService::isElementSelected },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/attribute/$name", &WebDriverService::getElementAttribute },
|
2017-12-04 11:29:29 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/property/$name", &WebDriverService::getElementProperty },
|
2018-01-22 14:33:32 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/css/$name", &WebDriverService::getElementCSSValue },
|
2017-07-18 07:20:33 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/text", &WebDriverService::getElementText },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/name", &WebDriverService::getElementTagName },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/rect", &WebDriverService::getElementRect },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/enabled", &WebDriverService::isElementEnabled },
|
|
|
|
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/element/$elementId/click", &WebDriverService::elementClick },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/element/$elementId/clear", &WebDriverService::elementClear },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/element/$elementId/value", &WebDriverService::elementSendKeys },
|
|
|
|
|
2019-11-08 15:09:00 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/source", &WebDriverService::getPageSource },
|
2017-07-18 07:20:33 +00:00
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/execute/sync", &WebDriverService::executeScript },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/execute/async", &WebDriverService::executeAsyncScript },
|
|
|
|
|
2017-08-28 11:52:55 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/cookie", &WebDriverService::getAllCookies },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/cookie/$name", &WebDriverService::getNamedCookie },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/cookie", &WebDriverService::addCookie },
|
|
|
|
{ HTTPMethod::Delete, "/session/$sessionId/cookie/$name", &WebDriverService::deleteCookie },
|
|
|
|
{ HTTPMethod::Delete, "/session/$sessionId/cookie", &WebDriverService::deleteAllCookies },
|
|
|
|
|
2018-05-10 06:52:31 +00:00
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/actions", &WebDriverService::performActions },
|
|
|
|
{ HTTPMethod::Delete, "/session/$sessionId/actions", &WebDriverService::releaseActions },
|
|
|
|
|
2017-08-08 06:22:02 +00:00
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/alert/dismiss", &WebDriverService::dismissAlert },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/alert/accept", &WebDriverService::acceptAlert },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/alert/text", &WebDriverService::getAlertText },
|
|
|
|
{ HTTPMethod::Post, "/session/$sessionId/alert/text", &WebDriverService::sendAlertText },
|
|
|
|
|
2017-08-28 13:55:10 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/screenshot", &WebDriverService::takeScreenshot },
|
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/screenshot", &WebDriverService::takeElementScreenshot },
|
|
|
|
|
|
|
|
|
2017-07-18 07:20:33 +00:00
|
|
|
{ HTTPMethod::Get, "/session/$sessionId/element/$elementId/displayed", &WebDriverService::isElementDisplayed },
|
|
|
|
};
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<WebDriverService::HTTPMethod> WebDriverService::toCommandHTTPMethod(const String& method)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
auto lowerCaseMethod = method.convertToASCIILowercase();
|
|
|
|
if (lowerCaseMethod == "get")
|
|
|
|
return WebDriverService::HTTPMethod::Get;
|
|
|
|
if (lowerCaseMethod == "post" || lowerCaseMethod == "put")
|
|
|
|
return WebDriverService::HTTPMethod::Post;
|
|
|
|
if (lowerCaseMethod == "delete")
|
|
|
|
return WebDriverService::HTTPMethod::Delete;
|
|
|
|
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-21 16:56:46 +00:00
|
|
|
bool WebDriverService::findCommand(HTTPMethod method, const String& path, CommandHandler* handler, HashMap<String, String>& parameters)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
size_t length = WTF_ARRAY_LENGTH(s_commands);
|
|
|
|
for (size_t i = 0; i < length; ++i) {
|
2017-11-21 16:56:46 +00:00
|
|
|
if (s_commands[i].method != method)
|
2017-07-18 07:20:33 +00:00
|
|
|
continue;
|
|
|
|
|
2018-07-26 22:00:03 +00:00
|
|
|
Vector<String> pathTokens = path.split('/');
|
|
|
|
Vector<String> commandTokens = String::fromUTF8(s_commands[i].uriTemplate).split('/');
|
2017-07-18 07:20:33 +00:00
|
|
|
if (pathTokens.size() != commandTokens.size())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bool allMatched = true;
|
|
|
|
for (size_t j = 0; j < pathTokens.size() && allMatched; ++j) {
|
|
|
|
if (commandTokens[j][0] == '$')
|
|
|
|
parameters.set(commandTokens[j].substring(1), pathTokens[j]);
|
|
|
|
else if (commandTokens[j] != pathTokens[j])
|
|
|
|
allMatched = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (allMatched) {
|
|
|
|
*handler = s_commands[i].handler;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
parameters.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebDriverService::handleRequest(HTTPRequestHandler::Request&& request, Function<void (HTTPRequestHandler::Response&&)>&& replyHandler)
|
|
|
|
{
|
2017-11-21 16:56:46 +00:00
|
|
|
auto method = toCommandHTTPMethod(request.method);
|
|
|
|
if (!method) {
|
|
|
|
sendResponse(WTFMove(replyHandler), CommandResult::fail(CommandResult::ErrorCode::UnknownCommand, String("Unknown method: " + request.method)));
|
|
|
|
return;
|
|
|
|
}
|
2017-07-18 07:20:33 +00:00
|
|
|
CommandHandler handler;
|
|
|
|
HashMap<String, String> parameters;
|
2017-11-21 16:56:46 +00:00
|
|
|
if (!findCommand(method.value(), request.path, &handler, parameters)) {
|
2017-07-18 07:20:33 +00:00
|
|
|
sendResponse(WTFMove(replyHandler), CommandResult::fail(CommandResult::ErrorCode::UnknownCommand, String("Unknown command: " + request.path)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
RefPtr<JSON::Object> parametersObject;
|
2019-01-29 10:37:06 +00:00
|
|
|
if (method.value() == HTTPMethod::Post) {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto messageValue = JSON::Value::parseJSON(String::fromUTF8(request.data, request.dataLength));
|
|
|
|
if (!messageValue) {
|
2017-07-18 07:20:33 +00:00
|
|
|
sendResponse(WTFMove(replyHandler), CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
parametersObject = messageValue->asObject();
|
|
|
|
if (!parametersObject) {
|
2017-07-18 07:20:33 +00:00
|
|
|
sendResponse(WTFMove(replyHandler), CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else
|
2017-11-28 19:58:16 +00:00
|
|
|
parametersObject = JSON::Object::create();
|
2017-07-18 07:20:33 +00:00
|
|
|
for (const auto& parameter : parameters)
|
|
|
|
parametersObject->setString(parameter.key, parameter.value);
|
|
|
|
|
|
|
|
((*this).*handler)(WTFMove(parametersObject), [this, replyHandler = WTFMove(replyHandler)](CommandResult&& result) mutable {
|
|
|
|
sendResponse(WTFMove(replyHandler), WTFMove(result));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebDriverService::sendResponse(Function<void (HTTPRequestHandler::Response&&)>&& replyHandler, CommandResult&& result) const
|
|
|
|
{
|
2017-09-20 06:29:17 +00:00
|
|
|
// §6.3 Processing Model.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#processing-model
|
2017-11-28 19:58:16 +00:00
|
|
|
RefPtr<JSON::Value> resultValue;
|
2017-07-18 07:20:33 +00:00
|
|
|
if (result.isError()) {
|
2017-09-20 06:29:17 +00:00
|
|
|
// When required to send an error.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-send-an-error
|
|
|
|
// Let body be a new JSON Object initialised with the following properties: "error", "message", "stacktrace".
|
2017-11-28 19:58:16 +00:00
|
|
|
auto errorObject = JSON::Object::create();
|
2018-06-23 08:39:34 +00:00
|
|
|
errorObject->setString("error"_s, result.errorString());
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
errorObject->setString("message"_s, result.errorMessage().value_or(emptyString()));
|
2018-06-23 08:39:34 +00:00
|
|
|
errorObject->setString("stacktrace"_s, emptyString());
|
2017-09-20 06:29:17 +00:00
|
|
|
// If the error data dictionary contains any entries, set the "data" field on body to a new JSON Object populated with the dictionary.
|
2017-08-08 06:43:25 +00:00
|
|
|
if (auto& additionalData = result.additionalErrorData())
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
errorObject->setObject("data"_s, *additionalData);
|
2017-09-20 06:29:17 +00:00
|
|
|
// Send a response with status and body as arguments.
|
|
|
|
resultValue = WTFMove(errorObject);
|
|
|
|
} else if (auto value = result.result())
|
|
|
|
resultValue = WTFMove(value);
|
|
|
|
else
|
2017-11-28 19:58:16 +00:00
|
|
|
resultValue = JSON::Value::null();
|
2017-09-20 06:29:17 +00:00
|
|
|
|
|
|
|
// When required to send a response.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-send-a-response
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto responseObject = JSON::Object::create();
|
|
|
|
responseObject->setValue("value"_s, resultValue.releaseNonNull());
|
2018-06-23 08:39:34 +00:00
|
|
|
replyHandler({ result.httpStatusCode(), responseObject->toJSONString().utf8(), "application/json; charset=utf-8"_s });
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<double> valueAsNumberInRange(const JSON::Value& value, double minAllowed = 0, double maxAllowed = std::numeric_limits<int>::max())
|
2018-01-10 16:16:22 +00:00
|
|
|
{
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto number = value.asDouble();
|
|
|
|
if (!number)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-01-26 09:50:58 +00:00
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (std::isnan(*number) || std::isinf(*number))
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-01-26 09:50:58 +00:00
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (*number < minAllowed || *number > maxAllowed)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-01-26 09:50:58 +00:00
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
return *number;
|
2018-01-26 09:50:58 +00:00
|
|
|
}
|
2018-01-10 16:16:22 +00:00
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<uint64_t> unsignedValue(JSON::Value& value)
|
2018-01-26 09:50:58 +00:00
|
|
|
{
|
|
|
|
auto number = valueAsNumberInRange(value, 0, maxSafeInteger);
|
|
|
|
if (!number)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-01-26 09:50:58 +00:00
|
|
|
|
|
|
|
auto intValue = static_cast<uint64_t>(number.value());
|
2018-01-10 16:16:22 +00:00
|
|
|
// If the contained value is a double, bail in case it doesn't match the integer
|
|
|
|
// value, i.e. if the double value was not originally in integer form.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-integer
|
2018-01-26 09:50:58 +00:00
|
|
|
if (number.value() != intValue)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-01-10 16:16:22 +00:00
|
|
|
|
2018-01-26 09:50:58 +00:00
|
|
|
return intValue;
|
2018-01-10 16:16:22 +00:00
|
|
|
}
|
|
|
|
|
2019-12-23 10:42:26 +00:00
|
|
|
enum class IgnoreUnknownTimeout { No, Yes };
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<Timeouts> deserializeTimeouts(JSON::Object& timeoutsObject, IgnoreUnknownTimeout ignoreUnknownTimeout)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
2017-08-05 09:27:15 +00:00
|
|
|
// §8.5 Set Timeouts.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-deserialize-as-a-timeout
|
|
|
|
Timeouts timeouts;
|
|
|
|
auto end = timeoutsObject.end();
|
|
|
|
for (auto it = timeoutsObject.begin(); it != end; ++it) {
|
|
|
|
if (it->key == "sessionId")
|
|
|
|
continue;
|
|
|
|
|
2019-12-23 10:42:26 +00:00
|
|
|
if (it->key == "script" && it->value->isNull()) {
|
|
|
|
timeouts.script = std::numeric_limits<double>::infinity();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-01-26 09:50:58 +00:00
|
|
|
// If value is not an integer, or it is less than 0 or greater than the maximum safe integer, return error with error code invalid argument.
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto timeoutMS = unsignedValue(it->value);
|
2018-01-26 09:50:58 +00:00
|
|
|
if (!timeoutMS)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-08-05 09:27:15 +00:00
|
|
|
|
|
|
|
if (it->key == "script")
|
2019-12-23 10:42:26 +00:00
|
|
|
timeouts.script = timeoutMS.value();
|
2017-08-05 09:27:15 +00:00
|
|
|
else if (it->key == "pageLoad")
|
2019-12-23 10:42:26 +00:00
|
|
|
timeouts.pageLoad = timeoutMS.value();
|
2017-08-05 09:27:15 +00:00
|
|
|
else if (it->key == "implicit")
|
2019-12-23 10:42:26 +00:00
|
|
|
timeouts.implicit = timeoutMS.value();
|
|
|
|
else if (ignoreUnknownTimeout == IgnoreUnknownTimeout::No)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
2017-08-05 09:27:15 +00:00
|
|
|
return timeouts;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<Proxy> deserializeProxy(JSON::Object& proxyObject)
|
2019-11-11 15:16:16 +00:00
|
|
|
{
|
|
|
|
// §7.1 Proxy.
|
|
|
|
// https://w3c.github.io/webdriver/#proxy
|
|
|
|
Proxy proxy;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
proxy.type = proxyObject.getString("proxyType"_s);
|
|
|
|
if (!proxy.type)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
|
|
|
|
if (proxy.type == "direct" || proxy.type == "autodetect" || proxy.type == "system")
|
|
|
|
return proxy;
|
|
|
|
|
|
|
|
if (proxy.type == "pac") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
proxy.autoconfigURL = proxyObject.getString("proxyAutoconfigUrl"_s);
|
|
|
|
if (!proxy.autoconfigURL)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
|
|
|
|
return proxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proxy.type == "manual") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = proxyObject.getValue("ftpProxy"_s)) {
|
|
|
|
auto ftpProxy = value->asString();
|
|
|
|
if (!ftpProxy)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
|
|
|
|
proxy.ftpURL = URL({ }, makeString("ftp://", ftpProxy));
|
|
|
|
if (!proxy.ftpURL->isValid())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = proxyObject.getValue("httpProxy"_s)) {
|
|
|
|
auto httpProxy = value->asString();
|
|
|
|
if (!httpProxy)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
|
|
|
|
proxy.httpURL = URL({ }, makeString("http://", httpProxy));
|
|
|
|
if (!proxy.httpURL->isValid())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = proxyObject.getValue("sslProxy"_s)) {
|
|
|
|
auto sslProxy = value->asString();
|
|
|
|
if (!sslProxy)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
|
|
|
|
proxy.httpsURL = URL({ }, makeString("https://", sslProxy));
|
|
|
|
if (!proxy.httpsURL->isValid())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = proxyObject.getValue("socksProxy")) {
|
|
|
|
auto socksProxy = value->asString();
|
|
|
|
if (!socksProxy)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
|
|
|
|
proxy.socksURL = URL({ }, makeString("socks://", socksProxy));
|
|
|
|
if (!proxy.socksURL->isValid())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto socksVersionValue = proxyObject.getValue("socksVersion");
|
|
|
|
if (!socksVersionValue)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
|
|
|
|
auto socksVersion = unsignedValue(*socksVersionValue);
|
|
|
|
if (!socksVersion || socksVersion.value() > 255)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
proxy.socksVersion = socksVersion.value();
|
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = proxyObject.getValue("noProxy"_s)) {
|
|
|
|
auto noProxy = value->asArray();
|
|
|
|
if (!noProxy)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
|
|
|
|
auto noProxyLength = noProxy->length();
|
|
|
|
for (unsigned i = 0; i < noProxyLength; ++i) {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto address = noProxy->get(i)->asString();
|
|
|
|
if (!address)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
proxy.ignoreAddressList.append(address);
|
2019-11-11 15:16:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return proxy;
|
|
|
|
}
|
|
|
|
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2019-11-11 15:16:16 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<PageLoadStrategy> deserializePageLoadStrategy(const String& pageLoadStrategy)
|
2017-08-05 11:14:34 +00:00
|
|
|
{
|
|
|
|
if (pageLoadStrategy == "none")
|
|
|
|
return PageLoadStrategy::None;
|
|
|
|
if (pageLoadStrategy == "normal")
|
|
|
|
return PageLoadStrategy::Normal;
|
|
|
|
if (pageLoadStrategy == "eager")
|
|
|
|
return PageLoadStrategy::Eager;
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-08-05 11:14:34 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<UnhandledPromptBehavior> deserializeUnhandledPromptBehavior(const String& unhandledPromptBehavior)
|
2017-08-08 06:43:25 +00:00
|
|
|
{
|
|
|
|
if (unhandledPromptBehavior == "dismiss")
|
|
|
|
return UnhandledPromptBehavior::Dismiss;
|
|
|
|
if (unhandledPromptBehavior == "accept")
|
|
|
|
return UnhandledPromptBehavior::Accept;
|
2017-12-15 13:14:36 +00:00
|
|
|
if (unhandledPromptBehavior == "dismiss and notify")
|
|
|
|
return UnhandledPromptBehavior::DismissAndNotify;
|
|
|
|
if (unhandledPromptBehavior == "accept and notify")
|
|
|
|
return UnhandledPromptBehavior::AcceptAndNotify;
|
2017-08-08 06:43:25 +00:00
|
|
|
if (unhandledPromptBehavior == "ignore")
|
|
|
|
return UnhandledPromptBehavior::Ignore;
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-08-08 06:43:25 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::parseCapabilities(const JSON::Object& matchedCapabilities, Capabilities& capabilities) const
|
2017-08-05 09:27:15 +00:00
|
|
|
{
|
|
|
|
// Matched capabilities have already been validated.
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto acceptInsecureCerts = matchedCapabilities.getBoolean("acceptInsecureCerts"_s);
|
|
|
|
if (acceptInsecureCerts)
|
|
|
|
capabilities.acceptInsecureCerts = *acceptInsecureCerts;
|
|
|
|
|
|
|
|
auto setWindowRect = matchedCapabilities.getBoolean("setWindowRect"_s);
|
|
|
|
if (setWindowRect)
|
|
|
|
capabilities.setWindowRect = *setWindowRect;
|
|
|
|
|
|
|
|
auto browserName = matchedCapabilities.getString("browserName"_s);
|
|
|
|
if (!!browserName)
|
2017-08-05 09:27:15 +00:00
|
|
|
capabilities.browserName = browserName;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
auto browserVersion = matchedCapabilities.getString("browserVersion"_s);
|
|
|
|
if (!!browserVersion)
|
2017-08-05 09:27:15 +00:00
|
|
|
capabilities.browserVersion = browserVersion;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
auto platformName = matchedCapabilities.getString("platformName"_s);
|
|
|
|
if (!!platformName)
|
2017-08-05 09:27:15 +00:00
|
|
|
capabilities.platformName = platformName;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
auto proxy = matchedCapabilities.getObject("proxy"_s);
|
|
|
|
if (proxy)
|
2019-11-11 15:16:16 +00:00
|
|
|
capabilities.proxy = deserializeProxy(*proxy);
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
auto strictFileInteractability = matchedCapabilities.getBoolean("strictFileInteractability"_s);
|
|
|
|
if (strictFileInteractability)
|
|
|
|
capabilities.strictFileInteractability = *strictFileInteractability;
|
|
|
|
|
|
|
|
auto timeouts = matchedCapabilities.getObject("timeouts"_s);
|
|
|
|
if (timeouts)
|
2019-12-23 10:42:26 +00:00
|
|
|
capabilities.timeouts = deserializeTimeouts(*timeouts, IgnoreUnknownTimeout::No);
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
auto pageLoadStrategy = matchedCapabilities.getString("pageLoadStrategy"_s);
|
|
|
|
if (!!pageLoadStrategy)
|
2017-08-05 11:14:34 +00:00
|
|
|
capabilities.pageLoadStrategy = deserializePageLoadStrategy(pageLoadStrategy);
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
auto unhandledPromptBehavior = matchedCapabilities.getString("unhandledPromptBehavior"_s);
|
|
|
|
if (!!unhandledPromptBehavior)
|
2017-08-08 06:43:25 +00:00
|
|
|
capabilities.unhandledPromptBehavior = deserializeUnhandledPromptBehavior(unhandledPromptBehavior);
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
2017-08-05 09:27:15 +00:00
|
|
|
platformParseCapabilities(matchedCapabilities, capabilities);
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
bool WebDriverService::findSessionOrCompleteWithError(JSON::Object& parameters, Function<void (CommandResult&&)>& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto sessionID = parameters.getString("sessionId"_s);
|
|
|
|
if (!sessionID) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
2017-12-01 09:47:15 +00:00
|
|
|
return false;
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!m_session || m_session->id() != sessionID) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidSessionID));
|
2017-12-01 09:47:15 +00:00
|
|
|
return false;
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2020-02-12 13:16:04 +00:00
|
|
|
if (!m_session->isConnected()) {
|
|
|
|
m_session = nullptr;
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidSessionID, String("session deleted because of page crash or hang.")));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
return true;
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
RefPtr<JSON::Object> WebDriverService::validatedCapabilities(const JSON::Object& capabilities) const
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
2017-08-05 09:27:15 +00:00
|
|
|
// §7.2 Processing Capabilities.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-validate-capabilities
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto result = JSON::Object::create();
|
2017-08-05 09:27:15 +00:00
|
|
|
auto end = capabilities.end();
|
|
|
|
for (auto it = capabilities.begin(); it != end; ++it) {
|
|
|
|
if (it->value->isNull())
|
2017-11-10 07:25:59 +00:00
|
|
|
continue;
|
|
|
|
if (it->key == "acceptInsecureCerts") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto acceptInsecureCerts = it->value->asBoolean();
|
|
|
|
if (!acceptInsecureCerts)
|
2017-08-05 09:27:15 +00:00
|
|
|
return nullptr;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
result->setBoolean(it->key, *acceptInsecureCerts);
|
2017-08-05 09:27:15 +00:00
|
|
|
} else if (it->key == "browserName" || it->key == "browserVersion" || it->key == "platformName") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto stringValue = it->value->asString();
|
|
|
|
if (!stringValue)
|
2017-08-05 09:27:15 +00:00
|
|
|
return nullptr;
|
|
|
|
result->setString(it->key, stringValue);
|
|
|
|
} else if (it->key == "pageLoadStrategy") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto pageLoadStrategy = it->value->asString();
|
|
|
|
if (!pageLoadStrategy || !deserializePageLoadStrategy(pageLoadStrategy))
|
2017-08-05 09:27:15 +00:00
|
|
|
return nullptr;
|
|
|
|
result->setString(it->key, pageLoadStrategy);
|
|
|
|
} else if (it->key == "proxy") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto proxy = it->value->asObject();
|
|
|
|
if (!proxy || !deserializeProxy(*proxy))
|
2019-11-11 15:16:16 +00:00
|
|
|
return nullptr;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
result->setValue(it->key, *proxy);
|
2019-12-03 10:03:32 +00:00
|
|
|
} else if (it->key == "strictFileInteractability") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto strictFileInteractability = it->value->asBoolean();
|
|
|
|
if (!strictFileInteractability)
|
2019-12-03 10:03:32 +00:00
|
|
|
return nullptr;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
result->setBoolean(it->key, *strictFileInteractability);
|
2017-08-05 09:27:15 +00:00
|
|
|
} else if (it->key == "timeouts") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto timeouts = it->value->asObject();
|
|
|
|
if (!timeouts || !deserializeTimeouts(*timeouts, IgnoreUnknownTimeout::No))
|
2017-08-05 09:27:15 +00:00
|
|
|
return nullptr;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
result->setValue(it->key, *timeouts);
|
2017-08-05 09:27:15 +00:00
|
|
|
} else if (it->key == "unhandledPromptBehavior") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto unhandledPromptBehavior = it->value->asString();
|
|
|
|
if (!unhandledPromptBehavior || !deserializeUnhandledPromptBehavior(unhandledPromptBehavior))
|
2017-08-05 09:27:15 +00:00
|
|
|
return nullptr;
|
|
|
|
result->setString(it->key, unhandledPromptBehavior);
|
|
|
|
} else if (it->key.find(":") != notFound) {
|
|
|
|
if (!platformValidateCapability(it->key, it->value))
|
|
|
|
return nullptr;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
result->setValue(it->key, it->value.copyRef());
|
2017-10-27 07:13:11 +00:00
|
|
|
} else
|
|
|
|
return nullptr;
|
2017-08-05 09:27:15 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
RefPtr<JSON::Object> WebDriverService::mergeCapabilities(const JSON::Object& requiredCapabilities, const JSON::Object& firstMatchCapabilities) const
|
2017-08-05 09:27:15 +00:00
|
|
|
{
|
|
|
|
// §7.2 Processing Capabilities.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-merging-capabilities
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto result = JSON::Object::create();
|
2017-08-05 09:27:15 +00:00
|
|
|
auto requiredEnd = requiredCapabilities.end();
|
|
|
|
for (auto it = requiredCapabilities.begin(); it != requiredEnd; ++it)
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
result->setValue(it->key, it->value.copyRef());
|
2017-08-05 09:27:15 +00:00
|
|
|
|
|
|
|
auto firstMatchEnd = firstMatchCapabilities.end();
|
2018-01-23 16:22:55 +00:00
|
|
|
for (auto it = firstMatchCapabilities.begin(); it != firstMatchEnd; ++it)
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
result->setValue(it->key, it->value.copyRef());
|
2017-08-05 09:27:15 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
RefPtr<JSON::Object> WebDriverService::matchCapabilities(const JSON::Object& mergedCapabilities) const
|
2017-08-05 09:27:15 +00:00
|
|
|
{
|
|
|
|
// §7.2 Processing Capabilities.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-matching-capabilities
|
2017-11-10 07:27:30 +00:00
|
|
|
Capabilities platformCapabilities = this->platformCapabilities();
|
2017-08-05 09:27:15 +00:00
|
|
|
|
|
|
|
// Some capabilities like browser name and version might need to launch the browser,
|
|
|
|
// so we only reject the known capabilities that don't match.
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto matchedCapabilities = JSON::Object::create();
|
2017-11-10 07:27:30 +00:00
|
|
|
if (platformCapabilities.browserName)
|
2018-06-23 08:39:34 +00:00
|
|
|
matchedCapabilities->setString("browserName"_s, platformCapabilities.browserName.value());
|
2017-11-10 07:27:30 +00:00
|
|
|
if (platformCapabilities.browserVersion)
|
2018-06-23 08:39:34 +00:00
|
|
|
matchedCapabilities->setString("browserVersion"_s, platformCapabilities.browserVersion.value());
|
2017-11-10 07:27:30 +00:00
|
|
|
if (platformCapabilities.platformName)
|
2018-06-23 08:39:34 +00:00
|
|
|
matchedCapabilities->setString("platformName"_s, platformCapabilities.platformName.value());
|
2017-11-10 07:27:30 +00:00
|
|
|
if (platformCapabilities.acceptInsecureCerts)
|
2018-06-23 08:39:34 +00:00
|
|
|
matchedCapabilities->setBoolean("acceptInsecureCerts"_s, platformCapabilities.acceptInsecureCerts.value());
|
2019-12-03 10:03:32 +00:00
|
|
|
if (platformCapabilities.strictFileInteractability)
|
|
|
|
matchedCapabilities->setBoolean("strictFileInteractability"_s, platformCapabilities.strictFileInteractability.value());
|
2018-01-23 16:20:36 +00:00
|
|
|
if (platformCapabilities.setWindowRect)
|
2018-06-23 08:39:34 +00:00
|
|
|
matchedCapabilities->setBoolean("setWindowRect"_s, platformCapabilities.setWindowRect.value());
|
2017-11-10 07:27:30 +00:00
|
|
|
|
2017-08-05 09:27:15 +00:00
|
|
|
auto end = mergedCapabilities.end();
|
|
|
|
for (auto it = mergedCapabilities.begin(); it != end; ++it) {
|
2017-11-10 07:27:30 +00:00
|
|
|
if (it->key == "browserName" && platformCapabilities.browserName) {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto browserName = it->value->asString();
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
if (!equalIgnoringASCIICase(platformCapabilities.browserName.value(), browserName))
|
2017-11-10 07:27:30 +00:00
|
|
|
return nullptr;
|
|
|
|
} else if (it->key == "browserVersion" && platformCapabilities.browserVersion) {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto browserVersion = it->value->asString();
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
if (!platformCompareBrowserVersions(browserVersion, platformCapabilities.browserVersion.value()))
|
2017-11-10 07:27:30 +00:00
|
|
|
return nullptr;
|
|
|
|
} else if (it->key == "platformName" && platformCapabilities.platformName) {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto platformName = it->value->asString();
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
if (!equalLettersIgnoringASCIICase(platformName, "any") && platformCapabilities.platformName.value() != platformName)
|
2017-11-10 07:27:30 +00:00
|
|
|
return nullptr;
|
|
|
|
} else if (it->key == "acceptInsecureCerts" && platformCapabilities.acceptInsecureCerts) {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto acceptInsecureCerts = it->value->asBoolean();
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
if (acceptInsecureCerts && !platformCapabilities.acceptInsecureCerts.value())
|
2017-11-10 07:27:30 +00:00
|
|
|
return nullptr;
|
2017-08-05 09:27:15 +00:00
|
|
|
} else if (it->key == "proxy") {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto proxyType = it->value->asObject()->getString("proxyType"_s);
|
2019-11-11 15:16:16 +00:00
|
|
|
if (!platformSupportProxyType(proxyType))
|
|
|
|
return nullptr;
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
} else if (!platformMatchCapability(it->key, it->value))
|
2017-11-10 07:27:30 +00:00
|
|
|
return nullptr;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
matchedCapabilities->setValue(it->key, it->value.copyRef());
|
2017-08-05 09:27:15 +00:00
|
|
|
}
|
|
|
|
|
2017-11-10 07:27:30 +00:00
|
|
|
return matchedCapabilities;
|
2017-08-05 09:27:15 +00:00
|
|
|
}
|
|
|
|
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
Vector<Capabilities> WebDriverService::processCapabilities(const JSON::Object& parameters, Function<void (CommandResult&&)>& completionHandler) const
|
2017-08-05 09:27:15 +00:00
|
|
|
{
|
|
|
|
// §7.2 Processing Capabilities.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#processing-capabilities
|
|
|
|
|
|
|
|
// 1. Let capabilities request be the result of getting the property "capabilities" from parameters.
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto capabilitiesObject = parameters.getObject("capabilities"_s);
|
|
|
|
if (!capabilitiesObject) {
|
2017-10-27 07:10:55 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
return { };
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
2017-08-05 09:27:15 +00:00
|
|
|
|
|
|
|
// 2. Let required capabilities be the result of getting the property "alwaysMatch" from capabilities request.
|
2017-11-28 19:58:16 +00:00
|
|
|
RefPtr<JSON::Object> requiredCapabilities;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto requiredCapabilitiesValue = capabilitiesObject->getValue("alwaysMatch"_s);
|
|
|
|
if (!requiredCapabilitiesValue) {
|
2017-08-05 09:27:15 +00:00
|
|
|
// 2.1. If required capabilities is undefined, set the value to an empty JSON Object.
|
2017-11-28 19:58:16 +00:00
|
|
|
requiredCapabilities = JSON::Object::create();
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
} else if (!(requiredCapabilities = requiredCapabilitiesValue->asObject())) {
|
2017-10-27 07:10:55 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument, String("alwaysMatch is invalid in capabilities")));
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
return { };
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-08-05 09:27:15 +00:00
|
|
|
// 2.2. Let required capabilities be the result of trying to validate capabilities with argument required capabilities.
|
|
|
|
requiredCapabilities = validatedCapabilities(*requiredCapabilities);
|
|
|
|
if (!requiredCapabilities) {
|
2017-10-27 07:10:55 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument, String("Invalid alwaysMatch capabilities")));
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
return { };
|
2017-08-05 09:27:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 3. Let all first match capabilities be the result of getting the property "firstMatch" from capabilities request.
|
2017-11-28 19:58:16 +00:00
|
|
|
RefPtr<JSON::Array> firstMatchCapabilitiesList;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto firstMatchCapabilitiesValue = capabilitiesObject->getValue("firstMatch"_s);
|
|
|
|
if (!firstMatchCapabilitiesValue) {
|
2017-08-05 09:27:15 +00:00
|
|
|
// 3.1. If all first match capabilities is undefined, set the value to a JSON List with a single entry of an empty JSON Object.
|
2017-11-28 19:58:16 +00:00
|
|
|
firstMatchCapabilitiesList = JSON::Array::create();
|
|
|
|
firstMatchCapabilitiesList->pushObject(JSON::Object::create());
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
} else {
|
|
|
|
firstMatchCapabilitiesList = firstMatchCapabilitiesValue->asArray();
|
|
|
|
if (!firstMatchCapabilitiesList) {
|
|
|
|
// 3.2. If all first match capabilities is not a JSON List, return error with error code invalid argument.
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument, String("firstMatch is invalid in capabilities")));
|
|
|
|
return { };
|
|
|
|
}
|
2017-08-05 09:27:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 4. Let validated first match capabilities be an empty JSON List.
|
2017-11-28 19:58:16 +00:00
|
|
|
Vector<RefPtr<JSON::Object>> validatedFirstMatchCapabilitiesList;
|
2017-08-05 09:27:15 +00:00
|
|
|
auto firstMatchCapabilitiesListLength = firstMatchCapabilitiesList->length();
|
|
|
|
validatedFirstMatchCapabilitiesList.reserveInitialCapacity(firstMatchCapabilitiesListLength);
|
|
|
|
// 5. For each first match capabilities corresponding to an indexed property in all first match capabilities.
|
|
|
|
for (unsigned i = 0; i < firstMatchCapabilitiesListLength; ++i) {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto firstMatchCapabilities = firstMatchCapabilitiesList->get(i)->asObject();
|
|
|
|
if (!firstMatchCapabilities) {
|
2017-10-27 07:10:55 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument, String("Invalid capabilities found in firstMatch")));
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
return { };
|
2017-08-05 09:27:15 +00:00
|
|
|
}
|
|
|
|
// 5.1. Let validated capabilities be the result of trying to validate capabilities with argument first match capabilities.
|
|
|
|
firstMatchCapabilities = validatedCapabilities(*firstMatchCapabilities);
|
|
|
|
if (!firstMatchCapabilities) {
|
2017-10-27 07:10:55 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument, String("Invalid firstMatch capabilities")));
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
return { };
|
2017-08-05 09:27:15 +00:00
|
|
|
}
|
2018-01-23 16:22:55 +00:00
|
|
|
|
|
|
|
// Validate here that firstMatchCapabilities don't shadow alwaysMatchCapabilities.
|
|
|
|
auto requiredEnd = requiredCapabilities->end();
|
|
|
|
auto firstMatchEnd = firstMatchCapabilities->end();
|
|
|
|
for (auto it = firstMatchCapabilities->begin(); it != firstMatchEnd; ++it) {
|
|
|
|
if (requiredCapabilities->find(it->key) != requiredEnd) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument,
|
|
|
|
makeString("Invalid firstMatch capabilities: key ", it->key, " is present in alwaysMatch")));
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
return { };
|
2018-01-23 16:22:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-05 09:27:15 +00:00
|
|
|
// 5.2. Append validated capabilities to validated first match capabilities.
|
|
|
|
validatedFirstMatchCapabilitiesList.uncheckedAppend(WTFMove(firstMatchCapabilities));
|
|
|
|
}
|
|
|
|
|
|
|
|
// 6. For each first match capabilities corresponding to an indexed property in validated first match capabilities.
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
Vector<Capabilities> matchedCapabilitiesList;
|
|
|
|
matchedCapabilitiesList.reserveInitialCapacity(validatedFirstMatchCapabilitiesList.size());
|
2017-08-05 09:27:15 +00:00
|
|
|
for (auto& validatedFirstMatchCapabilies : validatedFirstMatchCapabilitiesList) {
|
|
|
|
// 6.1. Let merged capabilities be the result of trying to merge capabilities with required capabilities and first match capabilities as arguments.
|
|
|
|
auto mergedCapabilities = mergeCapabilities(*requiredCapabilities, *validatedFirstMatchCapabilies);
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
|
2017-08-05 09:27:15 +00:00
|
|
|
// 6.2. Let matched capabilities be the result of trying to match capabilities with merged capabilities as an argument.
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
if (auto matchedCapabilities = matchCapabilities(*mergedCapabilities)) {
|
2017-08-05 09:27:15 +00:00
|
|
|
// 6.3. If matched capabilities is not null return matched capabilities.
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
Capabilities capabilities;
|
|
|
|
parseCapabilities(*matchedCapabilities, capabilities);
|
|
|
|
matchedCapabilitiesList.uncheckedAppend(WTFMove(capabilities));
|
2017-08-05 09:27:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
if (matchedCapabilitiesList.isEmpty()) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::SessionNotCreated, String("Failed to match capabilities")));
|
|
|
|
return { };
|
|
|
|
}
|
|
|
|
|
|
|
|
return matchedCapabilitiesList;
|
2017-08-05 09:27:15 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::newSession(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-05 09:27:15 +00:00
|
|
|
{
|
|
|
|
// §8.1 New Session.
|
|
|
|
// https://www.w3.org/TR/webdriver/#new-session
|
2017-12-01 09:47:15 +00:00
|
|
|
if (m_session) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::SessionNotCreated, String("Maximum number of active sessions")));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
auto matchedCapabilitiesList = processCapabilities(*parameters, completionHandler);
|
|
|
|
if (matchedCapabilitiesList.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Reverse the vector to always take last item.
|
|
|
|
matchedCapabilitiesList.reverse();
|
|
|
|
connectToBrowser(WTFMove(matchedCapabilitiesList), WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebDriverService::connectToBrowser(Vector<Capabilities>&& capabilitiesList, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
if (capabilitiesList.isEmpty()) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::SessionNotCreated, String("Failed to match capabilities")));
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
}
|
2017-07-18 07:20:33 +00:00
|
|
|
|
[WTF] Add makeUnique<T>, which ensures T is fast-allocated, makeUnique / makeUniqueWithoutFastMallocCheck part
https://bugs.webkit.org/show_bug.cgi?id=200620
Source/JavaScriptCore:
Reviewed by Geoff Garen.
* API/JSCallbackObject.h:
(JSC::JSCallbackObjectData::setPrivateProperty):
* API/JSCallbackObjectFunctions.h:
(JSC::JSCallbackObject<Parent>::JSCallbackObject):
* API/JSClassRef.cpp:
(OpaqueJSClassContextData::OpaqueJSClassContextData):
(OpaqueJSClass::contextData):
* API/JSMarkingConstraintPrivate.cpp:
(JSContextGroupAddMarkingConstraint):
* API/JSWrapperMap.mm:
(-[JSWrapperMap initWithGlobalContextRef:]):
* API/ObjCCallbackFunction.mm:
(ArgumentTypeDelegate::typeInteger):
(ArgumentTypeDelegate::typeDouble):
(ArgumentTypeDelegate::typeBool):
(ArgumentTypeDelegate::typeId):
(ArgumentTypeDelegate::typeOfClass):
(ArgumentTypeDelegate::typeStruct):
(ResultTypeDelegate::typeInteger):
(ResultTypeDelegate::typeDouble):
(ResultTypeDelegate::typeBool):
(ResultTypeDelegate::typeVoid):
(ResultTypeDelegate::typeId):
(ResultTypeDelegate::typeOfClass):
(ResultTypeDelegate::typeBlock):
(ResultTypeDelegate::typeStruct):
(objCCallbackFunctionForInvocation):
* API/glib/JSCContext.cpp:
(jscContextSetVirtualMachine):
* API/glib/JSCWrapperMap.cpp:
(JSC::WrapperMap::WrapperMap):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::ensurePageFor):
* b3/B3LowerToAir.cpp:
* b3/B3Procedure.cpp:
(JSC::B3::Procedure::Procedure):
(JSC::B3::Procedure::dominators):
(JSC::B3::Procedure::naturalLoops):
(JSC::B3::Procedure::backwardsCFG):
(JSC::B3::Procedure::backwardsDominators):
(JSC::B3::Procedure::addDataSection):
* b3/air/AirCode.cpp:
(JSC::B3::Air::Code::cCallSpecial):
* b3/air/AirGenerate.cpp:
(JSC::B3::Air::prepareForGeneration):
* b3/air/testair.cpp:
* b3/testb3.h:
(compileProc):
* bytecode/AccessCase.cpp:
(JSC::AccessCase::generateImpl):
* bytecode/AccessCaseSnippetParams.cpp:
* bytecode/BytecodeBasicBlock.cpp:
(JSC::BytecodeBasicBlock::computeImpl):
* bytecode/CallLinkInfo.cpp:
(JSC::CallLinkInfo::setFrameShuffleData):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureJITDataSlow):
(JSC::CodeBlock::setCalleeSaveRegisters):
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeOffsetSlow):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::createRareDataIfNecessary):
* bytecode/DFGExitProfile.cpp:
(JSC::DFG::ExitProfile::add):
* bytecode/DeferredCompilationCallback.cpp:
(JSC::DeferredCompilationCallback::ensureDeferredSourceDump):
* bytecode/GetByIdStatus.cpp:
(JSC::GetByIdStatus::computeForStubInfoWithoutExitSiteFeedback):
* bytecode/GetByIdVariant.cpp:
(JSC::GetByIdVariant::operator=):
* bytecode/LazyOperandValueProfile.cpp:
(JSC::CompressedLazyOperandValueProfileHolder::add):
* bytecode/PolyProtoAccessChain.h:
(JSC::PolyProtoAccessChain::clone):
* bytecode/PolymorphicAccess.cpp:
(JSC::PolymorphicAccess::regenerate):
* bytecode/PutByIdStatus.cpp:
(JSC::PutByIdStatus::computeForStubInfo):
* bytecode/PutByIdVariant.cpp:
(JSC::PutByIdVariant::operator=):
* bytecode/RecordedStatuses.cpp:
(JSC::RecordedStatuses::addCallLinkStatus):
(JSC::RecordedStatuses::addGetByIdStatus):
(JSC::RecordedStatuses::addPutByIdStatus):
(JSC::RecordedStatuses::addInByIdStatus):
* bytecode/StructureStubClearingWatchpoint.cpp:
(JSC::WatchpointsOnStructureStubInfo::ensureReferenceAndAddWatchpoint):
* bytecode/StructureStubInfo.cpp:
(JSC::StructureStubInfo::addAccessCase):
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::UnlinkedCodeBlock::livenessAnalysisSlow):
* bytecode/UnlinkedCodeBlock.h:
(JSC::UnlinkedCodeBlock::createRareDataIfNecessary):
* bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::UnlinkedFunctionExecutable::ensureRareDataSlow):
* bytecompiler/BytecodeGenerator.h:
(JSC::BytecodeGenerator::generate):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::AbstractInterpreter):
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::Graph):
(JSC::DFG::Graph::livenessFor):
(JSC::DFG::Graph::killsFor):
(JSC::DFG::Graph::ensureCPSCFG):
(JSC::DFG::Graph::ensureCPSDominators):
(JSC::DFG::Graph::ensureSSADominators):
(JSC::DFG::Graph::ensureCPSNaturalLoops):
(JSC::DFG::Graph::ensureSSANaturalLoops):
(JSC::DFG::Graph::ensureBackwardsCFG):
(JSC::DFG::Graph::ensureBackwardsDominators):
(JSC::DFG::Graph::ensureControlEquivalenceAnalysis):
* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::JITCompiler):
(JSC::DFG::JITCompiler::link):
(JSC::DFG::JITCompiler::compile):
(JSC::DFG::JITCompiler::compileFunction):
(JSC::DFG::JITCompiler::addressOfDoubleConstant):
* dfg/DFGLivenessAnalysisPhase.cpp:
* dfg/DFGPlan.cpp:
(JSC::DFG::Plan::compileInThreadImpl):
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::slowPathCall):
(JSC::DFG::slowPathMove):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::emitAllocateRawObject):
(JSC::DFG::SpeculativeJIT::arrayify):
(JSC::DFG::SpeculativeJIT::compileGetByValOnString):
(JSC::DFG::SpeculativeJIT::compileCreateDirectArguments):
(JSC::DFG::SpeculativeJIT::compileArraySlice):
(JSC::DFG::SpeculativeJIT::emitStructureCheck):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
* dfg/DFGStoreBarrierInsertionPhase.cpp:
* dfg/DFGWorklist.cpp:
(JSC::DFG::Worklist::createNewThread):
* disassembler/Disassembler.cpp:
(JSC::disassembleAsynchronously):
* ftl/FTLAbstractHeap.cpp:
(JSC::FTL::IndexedAbstractHeap::atSlow):
* ftl/FTLCompile.cpp:
(JSC::FTL::compile):
* ftl/FTLFail.cpp:
(JSC::FTL::fail):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::lazySlowPath):
* ftl/FTLState.cpp:
(JSC::FTL::State::State):
* heap/CompleteSubspace.cpp:
(JSC::CompleteSubspace::allocatorForSlow):
* heap/Heap.cpp:
(JSC::Heap::Heap):
(JSC::Heap::protectedObjectTypeCounts):
(JSC::Heap::objectTypeCounts):
(JSC::Heap::addCoreConstraints):
* heap/HeapInlines.h:
* heap/HeapSnapshotBuilder.cpp:
(JSC::HeapSnapshotBuilder::buildSnapshot):
* heap/IsoCellSet.cpp:
(JSC::IsoCellSet::addSlow):
* heap/IsoSubspace.cpp:
(JSC::IsoSubspace::IsoSubspace):
* heap/MarkingConstraintSet.cpp:
(JSC::MarkingConstraintSet::add):
* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::messageWithTypeAndLevel):
(Inspector::JSGlobalObjectConsoleClient::profile):
(Inspector::JSGlobalObjectConsoleClient::profileEnd):
(Inspector::JSGlobalObjectConsoleClient::warnUnimplemented):
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::reportAPIException):
(Inspector::JSGlobalObjectInspectorController::ensureInspectorAgent):
(Inspector::JSGlobalObjectInspectorController::ensureDebuggerAgent):
(Inspector::JSGlobalObjectInspectorController::createLazyAgents):
* inspector/agents/InspectorAgent.cpp:
(Inspector::InspectorAgent::InspectorAgent):
* inspector/agents/InspectorConsoleAgent.cpp:
(Inspector::InspectorConsoleAgent::InspectorConsoleAgent):
(Inspector::InspectorConsoleAgent::startTiming):
(Inspector::InspectorConsoleAgent::logTiming):
(Inspector::InspectorConsoleAgent::stopTiming):
(Inspector::InspectorConsoleAgent::count):
(Inspector::InspectorConsoleAgent::countReset):
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::InspectorDebuggerAgent):
* inspector/agents/InspectorHeapAgent.cpp:
(Inspector::InspectorHeapAgent::InspectorHeapAgent):
* inspector/agents/InspectorScriptProfilerAgent.cpp:
(Inspector::InspectorScriptProfilerAgent::InspectorScriptProfilerAgent):
* inspector/agents/InspectorTargetAgent.cpp:
(Inspector::InspectorTargetAgent::InspectorTargetAgent):
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
(Inspector::JSGlobalObjectDebuggerAgent::breakpointActionLog):
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
(Inspector::JSGlobalObjectRuntimeAgent::JSGlobalObjectRuntimeAgent):
* inspector/remote/socket/RemoteInspectorSocketEndpoint.cpp:
(Inspector::RemoteInspectorSocketEndpoint::createClient):
* inspector/remote/socket/RemoteInspectorSocketEndpoint.h:
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/tests/all/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/generic/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/generic/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/generic/expected/domain-availability.json-result:
* inspector/scripts/tests/generic/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/generic/expected/enum-values.json-result:
* inspector/scripts/tests/generic/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/mac/expected/definitions-with-mac-platform.json-result:
* jit/JIT.cpp:
(JSC::JIT::compileWithoutLinking):
(JSC::JIT::link):
* jit/JITThunks.cpp:
(JSC::JITThunks::JITThunks):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jsc.cpp:
(runJSC):
* parser/Parser.cpp:
(JSC::Parser<LexerType>::Parser):
* parser/Parser.h:
(JSC::Scope::pushLabel):
(JSC::Parser<LexerType>::parse):
* parser/ParserArena.h:
(JSC::ParserArena::identifierArena):
* profiler/ProfilerCompilation.cpp:
(JSC::Profiler::Compilation::executionCounterFor):
* runtime/Error.cpp:
(JSC::getStackTrace):
* runtime/FunctionExecutable.cpp:
(JSC::FunctionExecutable::ensureRareDataSlow):
* runtime/FunctionRareData.h:
(JSC::FunctionRareData::createAllocationProfileClearingWatchpoint):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::tryInstallArraySpeciesWatchpoint):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::createRareDataIfNeeded):
* runtime/JSRunLoopTimer.cpp:
(JSC::JSRunLoopTimer::Manager::PerVMData::PerVMData):
(JSC::JSRunLoopTimer::Manager::registerVM):
* runtime/PropertyMapHashTable.h:
(JSC::PropertyTable::addDeletedOffset):
* runtime/PropertyTable.cpp:
(JSC::PropertyTable::PropertyTable):
* runtime/RegExp.cpp:
(JSC::RegExp::finishCreation):
* runtime/RegExp.h:
* runtime/ScriptExecutable.cpp:
(JSC::ScriptExecutable::ensureTemplateObjectMapImpl):
* runtime/Structure.cpp:
(JSC::Structure::ensurePropertyReplacementWatchpointSet):
* runtime/StructureRareData.cpp:
(JSC::StructureRareData::setObjectToStringValue):
* runtime/SymbolTable.cpp:
(JSC::SymbolTable::localToEntry):
(JSC::SymbolTable::cloneScopePart):
(JSC::SymbolTable::prepareForTypeProfiling):
(JSC::SymbolTable::setRareDataCodeBlock):
* runtime/TypeSet.cpp:
(JSC::StructureShape::propertyHash):
* runtime/VM.cpp:
(JSC::VM::VM):
(JSC::VM::ensureHeapProfiler):
(JSC::VM::enableTypeProfiler):
(JSC::VM::enableControlFlowProfiler):
(JSC::VM::queueMicrotask):
(JSC::VM::ensureShadowChicken):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::emitPatchpoint):
(JSC::Wasm::AirIRGenerator::emitCheck):
(JSC::Wasm::parseAndCompileAir):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmBBQPlan.cpp:
(JSC::Wasm::BBQPlan::complete):
* wasm/WasmOMGPlan.cpp:
(JSC::Wasm::OMGPlan::work):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::Worklist):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* yarr/YarrInterpreter.cpp:
(JSC::Yarr::ByteCompiler::compile):
(JSC::Yarr::ByteCompiler::atomParenthesesSubpatternEnd):
(JSC::Yarr::ByteCompiler::regexBegin):
* yarr/YarrJIT.cpp:
(JSC::Yarr::YarrGenerator::compile):
* yarr/YarrPattern.cpp:
(JSC::Yarr::CharacterClassConstructor::charClass):
(JSC::Yarr::YarrPatternConstructor::YarrPatternConstructor):
(JSC::Yarr::YarrPatternConstructor::resetForReparsing):
(JSC::Yarr::YarrPatternConstructor::atomParenthesesSubpatternBegin):
(JSC::Yarr::YarrPatternConstructor::atomParentheticalAssertionBegin):
(JSC::Yarr::YarrPatternConstructor::copyDisjunction):
(JSC::Yarr::anycharCreate):
* yarr/YarrPattern.h:
(JSC::Yarr::PatternDisjunction::addNewAlternative):
* yarr/create_regex_tables:
* yarr/generateYarrUnicodePropertyTables.py:
Source/WebCore:
Reviewed by Geoff Garen.
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::logDeveloperWarning):
* Modules/beacon/NavigatorBeacon.cpp:
(WebCore::NavigatorBeacon::from):
* Modules/cache/DOMWindowCaches.cpp:
(WebCore::DOMWindowCaches::from):
* Modules/cache/WorkerGlobalScopeCaches.cpp:
(WebCore::WorkerGlobalScopeCaches::from):
* Modules/credentialmanagement/NavigatorCredentials.cpp:
(WebCore::NavigatorCredentials::from):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::InitDataRegistry::extractPsshBoxesFromCenc):
* Modules/encryptedmedia/legacy/LegacyCDM.cpp:
(WebCore::LegacyCDM::create):
* Modules/encryptedmedia/legacy/LegacyCDMPrivateClearKey.cpp:
(WebCore::LegacyCDMPrivateClearKey::createSession):
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::loadBlob):
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::fetch):
(WebCore::FetchResponse::BodyLoader::start):
* Modules/gamepad/NavigatorGamepad.cpp:
(WebCore::NavigatorGamepad::from):
* Modules/geolocation/GeolocationController.cpp:
(WebCore::provideGeolocationTo):
* Modules/geolocation/NavigatorGeolocation.cpp:
(WebCore::NavigatorGeolocation::from):
* Modules/indexeddb/DOMWindowIndexedDatabase.cpp:
(WebCore::DOMWindowIndexedDatabase::from):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::index):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::objectStore):
(WebCore::IDBTransaction::createObjectStore):
(WebCore::IDBTransaction::createIndex):
* Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp:
(WebCore::WorkerGlobalScopeIndexedDatabase::from):
* Modules/indexeddb/client/IDBConnectionToServer.cpp:
(WebCore::IDBClient::IDBConnectionToServer::IDBConnectionToServer):
* Modules/indexeddb/client/TransactionOperation.cpp:
(WebCore::IDBClient::TransactionOperation::TransactionOperation):
* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::getOrCreateUniqueIDBDatabase):
(WebCore::IDBServer::IDBServer::createBackingStore):
(WebCore::IDBServer::IDBServer::ensureQuotaUser):
* Modules/indexeddb/server/IndexValueStore.cpp:
(WebCore::IDBServer::IndexValueStore::addRecord):
* Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
(WebCore::IDBServer::MemoryBackingStoreTransaction::create):
(WebCore::IDBServer::MemoryBackingStoreTransaction::MemoryBackingStoreTransaction):
(WebCore::IDBServer::MemoryBackingStoreTransaction::recordValueChanged):
* Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
(WebCore::IDBServer::MemoryIDBBackingStore::create):
(WebCore::IDBServer::MemoryIDBBackingStore::getOrEstablishDatabaseInfo):
(WebCore::IDBServer::MemoryIDBBackingStore::setDatabaseInfo):
* Modules/indexeddb/server/MemoryIndex.cpp:
(WebCore::IDBServer::MemoryIndex::putIndexKey):
(WebCore::IDBServer::MemoryIndex::maybeOpenCursor):
* Modules/indexeddb/server/MemoryObjectStore.cpp:
(WebCore::IDBServer::MemoryObjectStore::addRecord):
(WebCore::IDBServer::MemoryObjectStore::maybeOpenCursor):
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::createAndPopulateInitialDatabaseInfo):
(WebCore::IDBServer::SQLiteIDBBackingStore::extractExistingDatabaseInfo):
(WebCore::IDBServer::SQLiteIDBBackingStore::getOrEstablishDatabaseInfo):
(WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction):
(WebCore::IDBServer::SQLiteIDBBackingStore::cachedStatement):
* Modules/indexeddb/server/SQLiteIDBCursor.cpp:
(WebCore::IDBServer::SQLiteIDBCursor::maybeCreate):
(WebCore::IDBServer::SQLiteIDBCursor::maybeCreateBackingStoreCursor):
(WebCore::IDBServer::SQLiteIDBCursor::createSQLiteStatement):
(WebCore::IDBServer::SQLiteIDBCursor::internalFetchNextRecord):
* Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
(WebCore::IDBServer::SQLiteIDBTransaction::begin):
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::didDeleteBackingStore):
(WebCore::IDBServer::UniqueIDBDatabase::didOpenBackingStore):
(WebCore::IDBServer::UniqueIDBDatabase::didPerformAbortTransaction):
* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::UniqueIDBDatabaseTransaction):
* Modules/indexeddb/shared/IDBRequestData.cpp:
(WebCore::IDBRequestData::IDBRequestData):
(WebCore::IDBRequestData::isolatedCopy):
* Modules/indexeddb/shared/IDBRequestData.h:
(WebCore::IDBRequestData::decode):
* Modules/indexeddb/shared/IDBResultData.cpp:
(WebCore::IDBResultData::IDBResultData):
(WebCore::IDBResultData::isolatedCopy):
(WebCore::IDBResultData::openDatabaseSuccess):
(WebCore::IDBResultData::openDatabaseUpgradeNeeded):
(WebCore::IDBResultData::deleteDatabaseSuccess):
(WebCore::IDBResultData::putOrAddSuccess):
(WebCore::IDBResultData::getRecordSuccess):
(WebCore::IDBResultData::getAllRecordsSuccess):
(WebCore::IDBResultData::openCursorSuccess):
(WebCore::IDBResultData::iterateCursorSuccess):
* Modules/indexeddb/shared/IDBResultData.h:
(WebCore::IDBResultData::decode):
* Modules/indexeddb/shared/IDBTransactionInfo.cpp:
(WebCore::IDBTransactionInfo::versionChange):
(WebCore::IDBTransactionInfo::IDBTransactionInfo):
(WebCore::IDBTransactionInfo::isolatedCopy):
* Modules/indexeddb/shared/IDBTransactionInfo.h:
(WebCore::IDBTransactionInfo::decode):
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::InProcessIDBServer::quotaManager):
* Modules/mediacapabilities/NavigatorMediaCapabilities.cpp:
(WebCore::NavigatorMediaCapabilities::from):
* Modules/mediasession/WebMediaSessionManager.cpp:
(WebCore::WebMediaSessionManager::mockPicker):
(WebCore::WebMediaSessionManager::addPlaybackTargetPickerClient):
* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::buffered const):
(WebCore::MediaSource::setLiveSeekableRange):
* Modules/mediastream/NavigatorMediaDevices.cpp:
(WebCore::NavigatorMediaDevices::from):
* Modules/mediastream/UserMediaController.cpp:
(WebCore::provideUserMediaTo):
* Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
(WebCore::LibWebRTCDataChannelHandler::channelEvent):
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::addRemoteTrack):
(WebCore::LibWebRTCMediaEndpoint::collectTransceivers):
(WebCore::LibWebRTCMediaEndpoint::newTransceiver):
(WebCore::LibWebRTCMediaEndpoint::createTransceiverBackends):
(WebCore::LibWebRTCMediaEndpoint::transceiverBackendFromSender):
(WebCore::LibWebRTCMediaEndpoint::createDataChannel):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::createLibWebRTCPeerConnectionBackend):
(WebCore::LibWebRTCPeerConnectionBackend::videoReceiver):
(WebCore::LibWebRTCPeerConnectionBackend::audioReceiver):
(WebCore::LibWebRTCPeerConnectionBackend::addTrack):
(WebCore::LibWebRTCPeerConnectionBackend::addTransceiver):
* Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp:
(WebCore::LibWebRTCRtpSenderBackend::createDTMFBackend):
* Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.cpp:
(WebCore::LibWebRTCRtpTransceiverBackend::createReceiverBackend):
(WebCore::LibWebRTCRtpTransceiverBackend::createSenderBackend):
* Modules/notifications/Notification.cpp:
(WebCore::Notification::Notification):
* Modules/notifications/NotificationController.cpp:
(WebCore::provideNotification):
* Modules/quota/DOMWindowQuota.cpp:
(WebCore::DOMWindowQuota::from):
* Modules/quota/NavigatorStorageQuota.cpp:
(WebCore::NavigatorStorageQuota::from):
* Modules/quota/WorkerNavigatorStorageQuota.cpp:
(WebCore::WorkerNavigatorStorageQuota::from):
* Modules/speech/DOMWindowSpeechSynthesis.cpp:
(WebCore::DOMWindowSpeechSynthesis::from):
* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::ensurePlatformSpeechSynthesizer):
* Modules/webaudio/AsyncAudioDecoder.cpp:
(WebCore::AsyncAudioDecoder::decodeAsync):
* Modules/webaudio/AudioBasicInspectorNode.cpp:
(WebCore::AudioBasicInspectorNode::AudioBasicInspectorNode):
* Modules/webaudio/AudioBasicProcessorNode.cpp:
(WebCore::AudioBasicProcessorNode::AudioBasicProcessorNode):
* Modules/webaudio/AudioBufferSourceNode.cpp:
(WebCore::AudioBufferSourceNode::AudioBufferSourceNode):
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::AudioContext):
(WebCore::AudioContext::decodeAudioData):
* Modules/webaudio/AudioDestinationNode.cpp:
(WebCore::AudioDestinationNode::AudioDestinationNode):
* Modules/webaudio/BiquadFilterNode.cpp:
(WebCore::BiquadFilterNode::BiquadFilterNode):
* Modules/webaudio/BiquadProcessor.cpp:
(WebCore::BiquadProcessor::createKernel):
(WebCore::BiquadProcessor::getFrequencyResponse):
* Modules/webaudio/ChannelMergerNode.cpp:
(WebCore::ChannelMergerNode::ChannelMergerNode):
* Modules/webaudio/ChannelSplitterNode.cpp:
(WebCore::ChannelSplitterNode::ChannelSplitterNode):
* Modules/webaudio/ConvolverNode.cpp:
(WebCore::ConvolverNode::ConvolverNode):
(WebCore::ConvolverNode::setBuffer):
* Modules/webaudio/DelayNode.cpp:
(WebCore::DelayNode::DelayNode):
* Modules/webaudio/DelayProcessor.cpp:
(WebCore::DelayProcessor::createKernel):
* Modules/webaudio/DynamicsCompressorNode.cpp:
(WebCore::DynamicsCompressorNode::DynamicsCompressorNode):
(WebCore::DynamicsCompressorNode::initialize):
* Modules/webaudio/GainNode.cpp:
(WebCore::GainNode::GainNode):
* Modules/webaudio/MediaElementAudioSourceNode.cpp:
(WebCore::MediaElementAudioSourceNode::MediaElementAudioSourceNode):
(WebCore::MediaElementAudioSourceNode::setFormat):
* Modules/webaudio/MediaStreamAudioSourceNode.cpp:
(WebCore::MediaStreamAudioSourceNode::MediaStreamAudioSourceNode):
(WebCore::MediaStreamAudioSourceNode::setFormat):
* Modules/webaudio/OscillatorNode.cpp:
(WebCore::OscillatorNode::OscillatorNode):
* Modules/webaudio/PannerNode.cpp:
(WebCore::PannerNode::PannerNode):
* Modules/webaudio/PeriodicWave.cpp:
(WebCore::PeriodicWave::createBandLimitedTables):
* Modules/webaudio/RealtimeAnalyser.cpp:
(WebCore::RealtimeAnalyser::RealtimeAnalyser):
(WebCore::RealtimeAnalyser::setFftSize):
* Modules/webaudio/ScriptProcessorNode.cpp:
(WebCore::ScriptProcessorNode::ScriptProcessorNode):
* Modules/webaudio/WaveShaperDSPKernel.cpp:
(WebCore::WaveShaperDSPKernel::lazyInitializeOversampling):
* Modules/webaudio/WaveShaperNode.cpp:
(WebCore::WaveShaperNode::WaveShaperNode):
* Modules/webaudio/WaveShaperProcessor.cpp:
(WebCore::WaveShaperProcessor::createKernel):
* Modules/webauthn/fido/FidoHidMessage.cpp:
(fido::FidoHidMessage::FidoHidMessage):
* Modules/webauthn/fido/FidoHidPacket.cpp:
(fido::FidoHidInitPacket::createFromSerializedData):
(fido::FidoHidContinuationPacket::createFromSerializedData):
* Modules/webdatabase/Database.cpp:
(WebCore::Database::openAndVerifyVersion):
(WebCore::Database::close):
(WebCore::Database::scheduleTransaction):
(WebCore::Database::scheduleTransactionStep):
(WebCore::Database::tableNames):
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::DatabaseThread):
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::addOpenDatabase):
(WebCore::DatabaseTracker::recordCreatingDatabase):
(WebCore::DatabaseTracker::recordDeletingDatabase):
* Modules/webdatabase/SQLTransaction.cpp:
(WebCore::SQLTransaction::executeSql):
(WebCore::SQLTransaction::openTransactionAndPreflight):
* Modules/webdriver/NavigatorWebDriver.cpp:
(WebCore::NavigatorWebDriver::from):
* Modules/webgpu/NavigatorGPU.cpp:
(WebCore::NavigatorGPU::from):
* Modules/webgpu/WHLSL/AST/WHLSLEnumerationDefinition.h:
* Modules/webgpu/WHLSL/AST/WHLSLVariableDeclaration.h:
* Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp:
(WebCore::WHLSL::Metal::RenderFunctionDefinitionWriter::createEntryPointScaffolding):
(WebCore::WHLSL::Metal::ComputeFunctionDefinitionWriter::createEntryPointScaffolding):
* Modules/webgpu/WHLSL/Metal/WHLSLTypeNamer.cpp:
(WebCore::WHLSL::Metal::TypeNamer::createNameNode):
* Modules/webgpu/WHLSL/WHLSLChecker.cpp:
(WebCore::WHLSL::Checker::assignConcreteType):
(WebCore::WHLSL::Checker::assignType):
(WebCore::WHLSL::Checker::forwardType):
* Modules/webgpu/WHLSL/WHLSLParser.cpp:
(WebCore::WHLSL::Parser::parseSemantic):
* Modules/webgpu/WorkerNavigatorGPU.cpp:
(WebCore::WorkerNavigatorGPU::from):
* Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
(WebCore::ThreadableWebSocketChannelClientWrapper::didConnect):
(WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessage):
(WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData):
(WebCore::ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmount):
(WebCore::ThreadableWebSocketChannelClientWrapper::didStartClosingHandshake):
(WebCore::ThreadableWebSocketChannelClientWrapper::didClose):
(WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageError):
(WebCore::ThreadableWebSocketChannelClientWrapper::didUpgradeURL):
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::connect):
(WebCore::WebSocketChannel::enqueueTextFrame):
(WebCore::WebSocketChannel::enqueueRawFrame):
(WebCore::WebSocketChannel::enqueueBlobFrame):
(WebCore::WebSocketChannel::processOutgoingFrameQueue):
* Modules/websockets/WebSocketDeflateFramer.cpp:
(WebCore::WebSocketDeflateFramer::createExtensionProcessor):
(WebCore::WebSocketDeflateFramer::enableDeflate):
(WebCore::WebSocketDeflateFramer::deflate):
(WebCore::WebSocketDeflateFramer::inflate):
* Modules/websockets/WebSocketDeflater.cpp:
(WebCore::WebSocketDeflater::WebSocketDeflater):
(WebCore::WebSocketInflater::WebSocketInflater):
* Modules/websockets/WorkerThreadableWebSocketChannel.cpp:
(WebCore::WorkerThreadableWebSocketChannel::Bridge::mainThreadInitialize):
* Modules/webvr/NavigatorWebVR.cpp:
(WebCore::NavigatorWebVR::from):
* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::startCachingComputedObjectAttributesUntilTreeMutates):
* animation/WebAnimation.cpp:
(WebCore::WebAnimation::updateFinishedState):
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::queueTaskToEventLoop):
* bindings/js/JSEventTargetCustom.cpp:
(WebCore::jsEventTargetCast):
* bindings/js/JSWorkerGlobalScopeBase.cpp:
(WebCore::JSWorkerGlobalScopeBase::queueTaskToEventLoop):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::transferArrayBuffers):
(WebCore::SerializedScriptValue::create):
* bindings/js/SerializedScriptValue.h:
(WebCore::SerializedScriptValue::decode):
* bindings/js/WebCoreJSClientData.cpp:
(WebCore::JSVMClientData::initNormalWorld):
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::initScript):
* bridge/c/c_class.cpp:
(JSC::Bindings::CClass::methodNamed const):
(JSC::Bindings::CClass::fieldNamed const):
* bridge/objc/objc_class.mm:
(JSC::Bindings::ObjcClass::methodNamed const):
(JSC::Bindings::ObjcClass::fieldNamed const):
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::callObjCFallbackObject):
* contentextensions/CombinedURLFilters.cpp:
(WebCore::ContentExtensions::CombinedURLFilters::CombinedURLFilters):
(WebCore::ContentExtensions::CombinedURLFilters::addPattern):
* crypto/SubtleCrypto.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::crossThreadCopyImportParams):
* css/CSSCalculationValue.cpp:
(WebCore::determineCategory):
* css/CSSDefaultStyleSheets.cpp:
(WebCore::CSSDefaultStyleSheets::loadFullDefaultStyle):
(WebCore::CSSDefaultStyleSheets::loadSimpleDefaultStyle):
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::appendSources):
* css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered):
* css/CSSGroupingRule.cpp:
(WebCore::CSSGroupingRule::cssRules const):
* css/CSSImageGeneratorValue.cpp:
(WebCore::CSSImageGeneratorValue::saveCachedImageForSize):
* css/CSSKeyframesRule.cpp:
(WebCore::CSSKeyframesRule::cssRules):
* css/CSSStyleSheet.cpp:
(WebCore::CSSStyleSheet::cssRules):
* css/DOMCSSPaintWorklet.cpp:
(WebCore::DOMCSSPaintWorklet::from):
* css/DOMCSSRegisterCustomProperty.cpp:
(WebCore::DOMCSSRegisterCustomProperty::from):
* css/DocumentRuleSets.cpp:
(WebCore::DocumentRuleSets::DocumentRuleSets):
(WebCore::DocumentRuleSets::updateUserAgentMediaQueryStyleIfNeeded const):
(WebCore::DocumentRuleSets::initializeUserStyle):
(WebCore::makeRuleSet):
(WebCore::DocumentRuleSets::resetAuthorStyle):
(WebCore::ensureInvalidationRuleSets):
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::collectSlottedPseudoElementRulesForSlot):
* css/FontFace.cpp:
(WebCore::populateFontFaceWithArrayBuffer):
* css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::PropertySetCSSStyleDeclaration::wrapForDeprecatedCSSOM):
* css/RuleFeature.cpp:
(WebCore::RuleFeatureSet::collectFeatures):
(WebCore::RuleFeatureSet::add):
* css/RuleSet.cpp:
(WebCore::RuleSet::addToRuleSet):
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertTo100PercentMinusLength):
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyTextOrBoxShadowValue):
(WebCore::StyleBuilderCustom::applyInheritTextShadow):
(WebCore::StyleBuilderCustom::applyInheritBoxShadow):
(WebCore::StyleBuilderCustom::applyValueContent):
* css/StyleProperties.cpp:
(WebCore::MutableStyleProperties::ensureCSSStyleDeclaration):
(WebCore::MutableStyleProperties::ensureInlineCSSStyleDeclaration):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::cascadedPropertiesForRollback):
* css/makeprop.pl:
(generateFillLayerPropertyInheritValueSetter):
(generateFillLayerPropertyValueSetter):
* css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::CSSParserImpl):
(WebCore::CSSParserImpl::parsePageSelector):
(WebCore::CSSParserImpl::consumeMediaRule):
(WebCore::CSSParserImpl::consumeSupportsRule):
(WebCore::CSSParserImpl::consumeKeyframesRule):
* css/parser/CSSParserSelector.cpp:
(WebCore::CSSParserSelector::parsePagePseudoSelector):
(WebCore::CSSParserSelector::parsePseudoElementSelector):
(WebCore::CSSParserSelector::parsePseudoClassSelector):
(WebCore::CSSParserSelector::CSSParserSelector):
(WebCore::CSSParserSelector::adoptSelectorVector):
(WebCore::CSSParserSelector::prependTagSelector):
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeBasicShapePath):
* css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParser::consumePseudo):
* dom/CustomElementReactionQueue.cpp:
(WebCore::CustomElementReactionQueue::ensureBackupQueue):
* dom/DataTransfer.cpp:
(WebCore::DataTransfer::items):
(WebCore::DataTransfer::createForInputEvent):
(WebCore::DataTransfer::createForDragStartEvent):
(WebCore::DataTransfer::setDragImage):
* dom/DeviceOrientationController.cpp:
(WebCore::provideDeviceOrientationTo):
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::buildAccessKeyCache):
(WebCore::Document::implementation):
(WebCore::Document::formController):
(WebCore::Document::updateTextRenderer):
(WebCore::Document::userAgentShadowTreeStyleResolver):
(WebCore::Document::axObjectCache const):
(WebCore::Document::setParsing):
(WebCore::Document::accessSVGExtensions):
(WebCore::Document::initSecurityContext):
(WebCore::Document::textAutoSizing):
(WebCore::Document::didAddWheelEventHandler):
(WebCore::Document::didAddTouchEventHandler):
(WebCore::Document::didLogMessage):
(WebCore::Document::registerCSSProperty):
(WebCore::Document::deviceOrientationAndMotionAccessController):
(WebCore::Document::contentChangeObserver):
(WebCore::Document::domTimerHoldingTank):
* dom/Document.h:
(WebCore::Document::createParserYieldToken):
* dom/DocumentEventQueue.cpp:
(WebCore::DocumentEventQueue::DocumentEventQueue):
* dom/DocumentMarkerController.cpp:
(WebCore::DocumentMarkerController::addMarker):
* dom/DocumentStorageAccess.cpp:
(WebCore::DocumentStorageAccess::from):
(WebCore::DocumentStorageAccess::requestStorageAccess):
(WebCore::DocumentStorageAccess::enableTemporaryTimeUserGesture):
* dom/Element.cpp:
(WebCore::Element::attributes const):
(WebCore::Element::setIsDefinedCustomElement):
(WebCore::Element::enqueueToUpgrade):
(WebCore::Element::classList):
(WebCore::Element::dataset):
(WebCore::Element::ensureIntersectionObserverData):
(WebCore::Element::ensureResizeObserverData):
* dom/EventListenerMap.cpp:
(WebCore::EventListenerMap::add):
* dom/EventNames.h:
* dom/EventPath.cpp:
(WebCore::EventPath::buildPath):
(WebCore::EventPath::EventPath):
* dom/IdTargetObserverRegistry.cpp:
(WebCore::IdTargetObserverRegistry::addObserver):
* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::KeyboardEvent):
* dom/MutationObserver.cpp:
(WebCore::queueMutationObserverCompoundMicrotask):
* dom/MutationObserverInterestGroup.cpp:
(WebCore::MutationObserverInterestGroup::createIfNeeded):
* dom/MutationObserverRegistration.cpp:
(WebCore::MutationObserverRegistration::observedSubtreeNodeWillDetach):
* dom/Node.cpp:
(WebCore::Node::materializeRareData):
(WebCore::Node::ensureEventTargetData):
(WebCore::Node::registerMutationObserver):
* dom/NodeRareData.h:
(WebCore::NodeRareData::ensureNodeLists):
(WebCore::NodeRareData::ensureMutationObserverData):
* dom/RadioButtonGroups.cpp:
(WebCore::RadioButtonGroups::addButton):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportException):
(WebCore::ScriptExecutionContext::reportUnhandledPromiseRejection):
(WebCore::ScriptExecutionContext::ensureRejectedPromiseTrackerSlow):
* dom/SelectorQuery.cpp:
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::ShadowRoot):
(WebCore::ShadowRoot::moveShadowRootToNewDocument):
(WebCore::ShadowRoot::addSlotElementByName):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::assignToSlot):
* dom/TreeScope.cpp:
(WebCore::TreeScope::TreeScope):
(WebCore::TreeScope::addElementById):
(WebCore::TreeScope::addElementByName):
(WebCore::TreeScope::addImageMap):
(WebCore::TreeScope::addImageElementByUsemap):
(WebCore::TreeScope::labelElementForId):
* editing/Editor.cpp:
(WebCore::createDataTransferForClipboardEvent):
(WebCore::Editor::Editor):
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::ensureReplacementFragment):
* editing/SelectionRectGatherer.cpp:
(WebCore::SelectionRectGatherer::clearAndCreateNotifier):
* editing/TextIterator.cpp:
(WebCore::TextIterator::handleTextNode):
* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::HTMLConverter):
(HTMLConverterCaches::computedStylePropertyForElement):
* editing/markup.cpp:
(WebCore::createPageForSanitizingWebContent):
* fileapi/AsyncFileStream.cpp:
(WebCore::callOnFileThread):
(WebCore::AsyncFileStream::AsyncFileStream):
* fileapi/FileReader.cpp:
(WebCore::FileReader::readInternal):
* history/CachedFrame.cpp:
(WebCore::CachedFrame::CachedFrame):
* history/CachedPage.cpp:
(WebCore::CachedPage::CachedPage):
* history/PageCache.cpp:
(WebCore::PageCache::addIfCacheable):
* html/FileInputType.cpp:
(WebCore::FileInputType::requestIcon):
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::resetFormAttributeTargetObserver):
* html/FormController.cpp:
(WebCore::SavedFormState::deserialize):
(WebCore::FormController::createSavedFormStateMap):
(WebCore::FormController::takeStateForFormElement):
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::relList const):
* html/HTMLAreaElement.cpp:
(WebCore::HTMLAreaElement::mapMouseEvent):
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::setImageBuffer const):
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::updateNamedElementCache const):
* html/HTMLDetailsElement.cpp:
(WebCore::HTMLDetailsElement::create):
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::updateVisibleValidationMessage):
* html/HTMLFormControlsCollection.cpp:
(WebCore::HTMLFormControlsCollection::updateNamedElementCache const):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::addToPastNamesMap):
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::sandbox):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::ensureImageLoader):
(WebCore::HTMLInputElement::resetListAttributeTargetObserver):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::sizes):
(WebCore::HTMLLinkElement::relList):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::finishInitialization):
(WebCore::HTMLMediaElement::seekWithTolerance):
* html/HTMLOutputElement.cpp:
(WebCore::HTMLOutputElement::htmlFor):
* html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::updateAfterStyleResolution):
* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::create):
* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::didAttachRenderers):
(WebCore::HTMLVideoElement::parseAttribute):
* html/PublicURLManager.cpp:
(WebCore::PublicURLManager::create):
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::setMessage):
(WebCore::ValidationMessage::setMessageDOMAndStartTimer):
(WebCore::ValidationMessage::requestToHideMessage):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::DisplayListDrawingContext::DisplayListDrawingContext):
(WebCore::CanvasRenderingContext2DBase::drawingContext const):
* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::getExtension):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::getExtension):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::initializeNewContext):
(WebCore::WebGLRenderingContextBase::compileShader):
(WebCore::WebGLRenderingContextBase::printToConsole):
* html/parser/CSSPreloadScanner.cpp:
(WebCore::CSSPreloadScanner::emitRule):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertHTMLElementOrFindCustomElementInterface):
* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::HTMLDocumentParser):
(WebCore::HTMLDocumentParser::pumpTokenizer):
(WebCore::HTMLDocumentParser::insert):
* html/parser/HTMLElementStack.cpp:
(WebCore::HTMLElementStack::insertAbove):
(WebCore::HTMLElementStack::pushCommon):
* html/parser/HTMLPreloadScanner.cpp:
(WebCore::TokenPreloadScanner::StartTagScanner::createPreloadRequest):
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginDOCTYPE):
* html/parser/XSSAuditor.cpp:
(WebCore::XSSAuditor::filterToken):
(WebCore::XSSAuditor::decodedHTTPBodySuffixTree):
* html/shadow/TextControlInnerElements.cpp:
(WebCore::TextControlInnerTextElement::resolveCustomStyle):
* html/track/InbandGenericTextTrack.cpp:
(WebCore::InbandGenericTextTrack::parser):
* html/track/InbandWebVTTTextTrack.cpp:
(WebCore::InbandWebVTTTextTrack::parser):
* html/track/LoadableTextTrack.cpp:
(WebCore::LoadableTextTrack::loadTimerFired):
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::CommandLineAPIHost):
(WebCore::CommandLineAPIHost::clearAllWrappers):
* inspector/DOMEditor.cpp:
(WebCore::DOMEditor::insertBefore):
(WebCore::DOMEditor::removeChild):
(WebCore::DOMEditor::setAttribute):
(WebCore::DOMEditor::removeAttribute):
(WebCore::DOMEditor::setOuterHTML):
(WebCore::DOMEditor::insertAdjacentHTML):
(WebCore::DOMEditor::replaceWholeText):
(WebCore::DOMEditor::replaceChild):
(WebCore::DOMEditor::setNodeValue):
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::createDigest):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::createLazyAgents):
(WebCore::InspectorController::ensureInspectorAgent):
(WebCore::InspectorController::ensureDOMAgent):
(WebCore::InspectorController::ensurePageAgent):
* inspector/InspectorHistory.cpp:
(WebCore::InspectorHistory::markUndoableState):
* inspector/InspectorStyleSheet.cpp:
(ParsedStyleSheet::setSourceData):
(WebCore::InspectorStyleSheet::ensureSourceData):
* inspector/NetworkResourcesData.cpp:
(WebCore::NetworkResourcesData::resourceCreated):
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::WorkerInspectorController):
(WebCore::WorkerInspectorController::connectFrontend):
(WebCore::WorkerInspectorController::createLazyAgents):
* inspector/agents/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::InspectorApplicationCacheAgent):
* inspector/agents/InspectorCPUProfilerAgent.cpp:
(WebCore::InspectorCPUProfilerAgent::InspectorCPUProfilerAgent):
* inspector/agents/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::InspectorCSSAgent):
(WebCore::InspectorCSSAgent::setStyleSheetText):
(WebCore::InspectorCSSAgent::setStyleText):
(WebCore::InspectorCSSAgent::setRuleSelector):
(WebCore::InspectorCSSAgent::addRule):
* inspector/agents/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
(WebCore::InspectorCanvasAgent::recordCanvasAction):
* inspector/agents/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::InspectorDOMAgent):
(WebCore::InspectorDOMAgent::didCreateFrontendAndBackend):
(WebCore::InspectorDOMAgent::pushNodePathToFrontend):
(WebCore::InspectorDOMAgent::highlightConfigFromInspectorObject):
(WebCore::InspectorDOMAgent::highlightRect):
(WebCore::InspectorDOMAgent::highlightQuad):
(WebCore::InspectorDOMAgent::innerHighlightQuad):
(WebCore::InspectorDOMAgent::highlightFrame):
(WebCore::InspectorDOMAgent::setInspectedNode):
(WebCore::InspectorDOMAgent::didInvalidateStyleAttr):
* inspector/agents/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::InspectorDOMStorageAgent):
* inspector/agents/InspectorDatabaseAgent.cpp:
(WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent):
* inspector/agents/InspectorLayerTreeAgent.cpp:
(WebCore::InspectorLayerTreeAgent::InspectorLayerTreeAgent):
* inspector/agents/InspectorMemoryAgent.cpp:
(WebCore::InspectorMemoryAgent::InspectorMemoryAgent):
* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::InspectorNetworkAgent):
* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::InspectorPageAgent):
* inspector/agents/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::internalStart):
(WebCore::InspectorTimelineAgent::startFromConsole):
(WebCore::InspectorTimelineAgent::stopFromConsole):
* inspector/agents/InspectorWorkerAgent.cpp:
(WebCore::InspectorWorkerAgent::InspectorWorkerAgent):
* inspector/agents/WebConsoleAgent.cpp:
(WebCore::WebConsoleAgent::didReceiveResponse):
(WebCore::WebConsoleAgent::didFailLoading):
* inspector/agents/WebHeapAgent.cpp:
(WebCore::WebHeapAgent::WebHeapAgent):
* inspector/agents/page/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::PageRuntimeAgent):
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
(WebCore::WorkerDebuggerAgent::breakpointActionLog):
* layout/LayoutState.cpp:
(WebCore::Layout::LayoutState::displayBoxForLayoutBox const):
(WebCore::Layout::LayoutState::createFormattingStateForFormattingRootIfNeeded):
(WebCore::Layout::LayoutState::createFormattingContext):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::collectInlineContent const):
* layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
(WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns const):
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::Line):
(WebCore::Layout::Line::appendNonBreakableSpace):
(WebCore::Layout::Line::appendTextContent):
(WebCore::Layout::Line::appendNonReplacedInlineBox):
(WebCore::Layout::Line::appendHardLineBreak):
* layout/inlineformatting/InlineTextItem.cpp:
(WebCore::Layout::InlineTextItem::createAndAppendTextItems):
(WebCore::Layout::InlineTextItem::split const):
* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::Box):
(WebCore::Layout::Box::ensureRareData):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createLayoutBox):
(WebCore::Layout::TreeBuilder::createTableStructure):
(WebCore::Layout::printLayoutTreeForLiveDocuments):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::appendCell):
* loader/ContentFilter.cpp:
(WebCore::ContentFilter::create):
* loader/CrossOriginAccessControl.cpp:
(WebCore::validatePreflightResponse):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::DocumentLoader):
(WebCore::DocumentLoader::loadApplicationManifest):
(WebCore::DocumentLoader::addAllArchiveResources):
(WebCore::DocumentLoader::addArchiveResource):
(WebCore::DocumentLoader::loadMainResource):
(WebCore::DocumentLoader::didGetLoadDecisionForIcon):
* loader/EmptyClients.cpp:
(WebCore::pageConfigurationWithEmptyClients):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::FrameLoader):
(WebCore::FrameLoader::init):
(WebCore::FrameLoader::initForSynthesizedDocument):
(WebCore::FrameLoader::detachChildren):
* loader/LinkLoader.cpp:
(WebCore::createLinkPreloadResourceClient):
* loader/NavigationScheduler.cpp:
(WebCore::NavigationScheduler::scheduleRedirect):
(WebCore::NavigationScheduler::scheduleLocationChange):
(WebCore::NavigationScheduler::scheduleFormSubmission):
(WebCore::NavigationScheduler::scheduleRefresh):
(WebCore::NavigationScheduler::scheduleHistoryNavigation):
(WebCore::NavigationScheduler::schedulePageBlock):
* loader/ProgressTracker.cpp:
(WebCore::ProgressTracker::incrementProgress):
* loader/TextResourceDecoder.cpp:
(WebCore::TextResourceDecoder::checkForHeadCharset):
* loader/TextTrackLoader.cpp:
(WebCore::TextTrackLoader::processNewCueData):
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create):
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::setBodyDataFrom):
(WebCore::CachedImage::createImage):
* loader/cache/CachedRawResource.cpp:
(WebCore::CachedRawResource::redirectReceived):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::addClientToSet):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::preload):
(WebCore::CachedResourceLoader::clearPreloads):
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::ensureSessionResourceMap):
(WebCore::MemoryCache::addImageToCache):
(WebCore::MemoryCache::lruListFor):
* loader/ios/PreviewLoader.mm:
(-[WebPreviewLoader initWithResourceLoader:resourceResponse:]):
(-[WebPreviewLoader connection:didFailWithError:]):
(WebCore::PreviewLoader::create):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::maybeCreateContextMenu):
* page/DebugPageOverlays.cpp:
(WebCore::MouseWheelRegionOverlay::updateRegion):
* page/EventHandler.cpp:
(WebCore::EventHandler::EventHandler):
* page/FrameView.cpp:
(WebCore::FrameView::addEmbeddedObjectToUpdate):
(WebCore::FrameView::addSlowRepaintObject):
(WebCore::FrameView::addViewportConstrainedObject):
(WebCore::FrameView::addScrollableArea):
* page/FrameViewLayoutContext.cpp:
(WebCore::FrameViewLayoutContext::pushLayoutState):
(WebCore::FrameViewLayoutContext::pushLayoutStateForPaginationIfNeeded):
* page/NavigatorBase.cpp:
(WebCore::NavigatorBase::serviceWorker):
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::initGroup):
(WebCore::Page::setResourceUsageOverlayVisible):
* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::addMessage):
(WebCore::PageConsoleClient::messageWithTypeAndLevel):
(WebCore::PageConsoleClient::screenshot):
* page/PageGroup.cpp:
(WebCore::PageGroup::captionPreferences):
* page/Performance.cpp:
(WebCore::Performance::mark):
(WebCore::Performance::clearMarks):
(WebCore::Performance::measure):
(WebCore::Performance::clearMeasures):
* page/PrintContext.cpp:
(WebCore::PrintContext::outputLinkedDestinations):
* page/RenderingUpdateScheduler.cpp:
(WebCore::RenderingUpdateScheduler::startTimer):
* page/RenderingUpdateScheduler.h:
(WebCore::RenderingUpdateScheduler::create):
* page/SecurityPolicy.cpp:
(WebCore::SecurityPolicy::addOriginAccessWhitelistEntry):
* page/SettingsBase.cpp:
(WebCore::SettingsBase::SettingsBase):
* page/UserContentController.cpp:
(WebCore::UserContentController::addUserScript):
(WebCore::UserContentController::addUserStyleSheet):
* page/WheelEventDeltaFilter.cpp:
(WebCore::WheelEventDeltaFilter::create):
* page/animation/CSSAnimationController.cpp:
(WebCore::CSSAnimationController::CSSAnimationController):
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::blendFunc):
(WebCore::PropertyWrapperVisitedAffectedColor::PropertyWrapperVisitedAffectedColor):
(WebCore::FillLayersPropertyWrapper::FillLayersPropertyWrapper):
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::updateSourceSelf):
* page/csp/ContentSecurityPolicyDirectiveList.cpp:
(WebCore::ContentSecurityPolicyDirectiveList::create):
(WebCore::ContentSecurityPolicyDirectiveList::setCSPDirective):
* page/linux/ResourceUsageOverlayLinux.cpp:
(WebCore::ResourceUsageOverlay::platformInitialize):
* page/mac/PageMac.mm:
(WebCore::Page::addSchedulePair):
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::AsyncScrollingCoordinator):
* page/scrolling/ScrollingMomentumCalculator.cpp:
(WebCore::ScrollingMomentumCalculator::create):
* page/scrolling/ScrollingStateNode.cpp:
(WebCore::ScrollingStateNode::appendChild):
(WebCore::ScrollingStateNode::insertChild):
* page/scrolling/ScrollingStateTree.cpp:
(WebCore::ScrollingStateTree::commit):
* page/scrolling/ScrollingTreeNode.cpp:
(WebCore::ScrollingTreeNode::appendChild):
* page/scrolling/mac/ScrollingMomentumCalculatorMac.mm:
(WebCore::ScrollingMomentumCalculator::create):
* platform/Length.cpp:
(WebCore::convertTo100PercentMinusLength):
(WebCore::blendMixedTypes):
* platform/RemoteCommandListener.cpp:
(WebCore::RemoteCommandListener::create):
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::create):
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::scrollAnimator const):
(WebCore::ScrollableArea::ensureSnapOffsetsInfo):
* platform/ThreadGlobalData.cpp:
(WebCore::ThreadGlobalData::ThreadGlobalData):
* platform/audio/AudioBus.cpp:
(WebCore::AudioBus::AudioBus):
(WebCore::AudioBus::copyWithGainFrom):
* platform/audio/AudioChannel.h:
* platform/audio/AudioResampler.cpp:
(WebCore::AudioResampler::AudioResampler):
(WebCore::AudioResampler::configureChannels):
* platform/audio/DynamicsCompressor.cpp:
(WebCore::DynamicsCompressor::setNumberOfChannels):
* platform/audio/DynamicsCompressorKernel.cpp:
(WebCore::DynamicsCompressorKernel::setNumberOfChannels):
* platform/audio/FFTFrame.cpp:
(WebCore::FFTFrame::createInterpolatedFrame):
* platform/audio/HRTFDatabaseLoader.cpp:
(WebCore::HRTFDatabaseLoader::load):
* platform/audio/HRTFElevation.cpp:
(WebCore::HRTFElevation::createForSubject):
(WebCore::HRTFElevation::createByInterpolatingSlices):
* platform/audio/HRTFKernel.cpp:
(WebCore::HRTFKernel::HRTFKernel):
(WebCore::HRTFKernel::createImpulseResponse):
* platform/audio/MultiChannelResampler.cpp:
(WebCore::MultiChannelResampler::MultiChannelResampler):
* platform/audio/Panner.cpp:
(WebCore::Panner::create):
* platform/audio/PlatformMediaSession.cpp:
(WebCore::PlatformMediaSession::create):
* platform/audio/Reverb.cpp:
(WebCore::Reverb::initialize):
* platform/audio/ReverbConvolver.cpp:
(WebCore::ReverbConvolver::ReverbConvolver):
* platform/audio/ReverbConvolverStage.cpp:
(WebCore::ReverbConvolverStage::ReverbConvolverStage):
* platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
(WebCore::AudioDestination::create):
* platform/audio/ios/AudioDestinationIOS.cpp:
(WebCore::AudioDestination::create):
* platform/audio/ios/AudioSessionIOS.mm:
(WebCore::AudioSession::AudioSession):
* platform/audio/mac/AudioDestinationMac.cpp:
(WebCore::AudioDestination::create):
* platform/audio/mac/AudioSampleDataSource.mm:
(WebCore::AudioSampleDataSource::setInputFormat):
(WebCore::AudioSampleDataSource::setOutputFormat):
* platform/audio/mac/AudioSessionMac.cpp:
(WebCore::AudioSession::AudioSession):
* platform/cf/KeyedDecoderCF.cpp:
(WebCore::KeyedDecoder::decoder):
* platform/cf/KeyedEncoderCF.cpp:
(WebCore::KeyedEncoder::encoder):
* platform/cf/MainThreadSharedTimerCF.cpp:
(WebCore::setupPowerObserver):
* platform/cocoa/NetworkExtensionContentFilter.mm:
(WebCore::NetworkExtensionContentFilter::create):
* platform/cocoa/ParentalControlsContentFilter.mm:
(WebCore::ParentalControlsContentFilter::create):
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::updateScrollSnapPoints):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::CDMFactoryClearKey::createCDM):
* platform/gamepad/cocoa/GameControllerGamepadProvider.mm:
(WebCore::GameControllerGamepadProvider::controllerDidConnect):
* platform/gamepad/mac/HIDGamepadProvider.cpp:
(WebCore::HIDGamepadProvider::deviceAdded):
* platform/generic/KeyedDecoderGeneric.cpp:
(WebCore::KeyedDecoderGeneric::Dictionary::add):
(WebCore::KeyedDecoder::decoder):
(WebCore::KeyedDecoderGeneric::KeyedDecoderGeneric):
* platform/generic/KeyedEncoderGeneric.cpp:
(WebCore::KeyedEncoder::encoder):
* platform/generic/ScrollAnimatorGeneric.cpp:
(WebCore::ScrollAnimator::create):
(WebCore::ScrollAnimatorGeneric::ScrollAnimatorGeneric):
(WebCore::ScrollAnimatorGeneric::ensureSmoothScrollingAnimation):
* platform/glib/KeyedDecoderGlib.cpp:
(WebCore::KeyedDecoder::decoder):
* platform/glib/KeyedEncoderGlib.cpp:
(WebCore::KeyedEncoder::encoder):
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::startTimer):
(WebCore::BitmapImage::decode):
* platform/graphics/ComplexTextController.cpp:
(WebCore::TextLayout::TextLayout):
* platform/graphics/Font.cpp:
(WebCore::Font::ensureDerivedFontData const):
* platform/graphics/Font.h:
(WebCore::Font::boundsForGlyph const):
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::getCachedFontPlatformData):
* platform/graphics/FontCascade.cpp:
(WebCore::retrieveOrAddCachedFonts):
(WebCore::FontCascade::displayListForTextRun const):
* platform/graphics/FontCascadeFonts.cpp:
(WebCore::FontCascadeFonts::GlyphPageCacheEntry::setGlyphDataForCharacter):
* platform/graphics/GlyphMetricsMap.h:
(WebCore::GlyphMetricsMap<T>::locatePageSlowCase):
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::setTransform):
(WebCore::GraphicsLayer::setChildrenTransform):
* platform/graphics/GraphicsLayer.h:
* platform/graphics/Image.cpp:
(WebCore::Image::startAnimationAsynchronously):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::MediaPlayer):
(WebCore::MediaPlayer::loadWithNextMediaEngine):
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::seekable const):
* platform/graphics/PathUtilities.cpp:
(WebCore::FloatPointGraph::findOrCreateNode):
* platform/graphics/Region.cpp:
(WebCore::Region::setShape):
* platform/graphics/Region.h:
(WebCore::Region::copyShape const):
(WebCore::Region::decode):
* platform/graphics/TextTrackRepresentation.cpp:
(WebCore::TextTrackRepresentation::create):
* platform/graphics/angle/GraphicsContext3DANGLE.cpp:
(WebCore::GraphicsContext3D::getExtensions):
* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
(WebCore::AudioSourceProviderAVFObjC::prepare):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::CDMFactoryFairPlayStreaming::createCDM):
* platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
(WebCore::CDMPrivateMediaSourceAVFObjC::createSession):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::buffered const):
* platform/graphics/avfoundation/WebMediaSessionManagerMac.cpp:
(WebCore::WebMediaSessionManagerMac::platformPicker):
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::MediaPlayerPrivateAVFoundationCF::registerMediaEngine):
(WebCore::MediaPlayerPrivateAVFoundationCF::platformBufferedTimeRanges const):
(WebCore::MediaPlayerPrivateAVFoundationCF::createSession):
(WebCore::AVFWrapper::notificationCallback):
(WebCore::AVFWrapper::legibleOutputCallback):
(WebCore::AVFWrapper::resourceLoaderShouldWaitForLoadingOfRequestedResource):
(WebCore::AVFWrapper::platformLayer):
* platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.mm:
(WebCore::AudioTrackPrivateAVFObjC::AudioTrackPrivateAVFObjC):
(WebCore::AudioTrackPrivateAVFObjC::setPlayerItemTrack):
(WebCore::AudioTrackPrivateAVFObjC::setAssetTrack):
(WebCore::AudioTrackPrivateAVFObjC::setMediaSelectionOption):
* platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp:
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::AudioTrackPrivateMediaSourceAVFObjC):
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::setAssetTrack):
* platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
(WebCore::ImageDecoderAVFObjC::readTrackMetadata):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::registerMediaEngine):
(WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
(WebCore::MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeRanges const):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateRotationSession):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
(WebCore::MediaPlayerPrivateAVFoundationObjC::copyVideoTextureToPlatformTexture):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createSession):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekable const):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::buffered const):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastImage):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::copyVideoTextureToPlatformTexture):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::registerMediaEngine):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::seekable const):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::buffered const):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::updateCurrentFrameImage):
* platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.cpp:
(WebCore::VideoTrackPrivateAVFObjC::VideoTrackPrivateAVFObjC):
(WebCore::VideoTrackPrivateAVFObjC::setPlayerItemTrack):
(WebCore::VideoTrackPrivateAVFObjC::setAssetTrack):
(WebCore::VideoTrackPrivateAVFObjC::setMediaSelectonOption):
* platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.mm:
(WebCore::VideoTrackPrivateMediaSourceAVFObjC::VideoTrackPrivateMediaSourceAVFObjC):
(WebCore::VideoTrackPrivateMediaSourceAVFObjC::setAssetTrack):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::recursiveCommitChanges):
(WebCore::GraphicsLayerCA::ensureLayerAnimations):
(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::TileController):
(WebCore::TileController::setContentsScale):
(WebCore::TileController::adjustTileCoverageRectForScrolling):
(WebCore::TileController::tiledScrollingIndicatorLayer):
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(WebCore::PlatformCALayerCocoa::commonInit):
(WebCore::PlatformCALayerCocoa::setShapeRoundedRect):
* platform/graphics/ca/cocoa/WebTiledBackingLayer.mm:
(-[WebTiledBackingLayer createTileController:]):
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
(PlatformCALayerWin::PlatformCALayerWin):
* platform/graphics/ca/win/WebTiledBackingLayerWin.cpp:
(WebTiledBackingLayerWin::createTileController):
* platform/graphics/cairo/GraphicsContextImplCairo.cpp:
(WebCore::GraphicsContextImplCairo::createFactory):
(WebCore::m_private):
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBufferData::swapBuffersIfNeeded):
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontCache::createFontPlatformData):
* platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:
(WebCore::FontFamilySpecificationCoreText::fontRanges const):
* platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
(WebCore::GraphicsContext3D::GraphicsContext3D):
* platform/graphics/cocoa/IOSurface.mm:
(WebCore::IOSurface::ensureGraphicsContext):
* platform/graphics/cocoa/TextTrackRepresentationCocoa.mm:
(TextTrackRepresentation::create):
* platform/graphics/cv/TextureCacheCV.mm:
(WebCore::TextureCacheCV::create):
* platform/graphics/displaylists/DisplayListReplayer.cpp:
(WebCore::DisplayList::Replayer::replay):
* platform/graphics/filters/FilterOperation.cpp:
(WebCore::ReferenceFilterOperation::loadExternalDocumentIfNeeded):
* platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::FontCache::createFontPlatformData):
* platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
(WebCore::createFontCustomPlatformData):
* platform/graphics/gpu/Texture.cpp:
(WebCore::Texture::create):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::registerMediaEngine):
(WebCore::MediaPlayerPrivateGStreamer::buffered const):
(WebCore::MediaPlayerPrivateGStreamer::ensureAudioSourceProvider):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::pushTextureToCompositor):
(WebCore::MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture):
(WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
(WebCore::MediaPlayerPrivateGStreamerBase::pushNextHolePunchBuffer):
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webKitWebSrcMakeRequest):
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::registerMediaEngine):
(WebCore::MediaPlayerPrivateGStreamerMSE::buffered const):
* platform/graphics/holepunch/MediaPlayerPrivateHolePunch.cpp:
(WebCore::MediaPlayerPrivateHolePunch::pushNextHolePunchBuffer):
(WebCore::MediaPlayerPrivateHolePunch::registerMediaEngine):
* platform/graphics/holepunch/MediaPlayerPrivateHolePunch.h:
* platform/graphics/iso/ISOProtectionSchemeInfoBox.cpp:
(WebCore::ISOProtectionSchemeInfoBox::parse):
* platform/graphics/iso/ISOSchemeInformationBox.cpp:
(WebCore::ISOSchemeInformationBox::parse):
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::createFontCustomPlatformData):
* platform/graphics/nicosia/NicosiaSceneIntegration.cpp:
(Nicosia::SceneIntegration::createUpdateScope):
* platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp:
(Nicosia::createCommand):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
(Nicosia::PaintingContextCairo::ForRecording::ForRecording):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createFactory):
* platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.cpp:
(Nicosia::CompositionLayerTextureMapperImpl::createFactory):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::createFactory):
* platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp:
(Nicosia::GC3DLayer::swapBuffersIfNeeded):
* platform/graphics/nicosia/texmap/NicosiaImageBackingTextureMapperImpl.cpp:
(Nicosia::ImageBackingTextureMapperImpl::createFactory):
* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
(WebCore::GraphicsContext3D::getExtensions):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::compileShader):
(WebCore::GraphicsContext3D::mappedSymbolName):
* platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
(WebCore::GraphicsContext3D::getExtensions):
(WebCore::GraphicsContext3D::GraphicsContext3D):
* platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp:
(WebCore::GraphicsContext3D::GraphicsContext3D):
(WebCore::GraphicsContext3D::getExtensions):
* platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp:
(WebCore::TextureMapperGC3DPlatformLayer::swapBuffersIfNeeded):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::TextureMapperGL):
(WebCore::TextureMapper::platformCreateAccelerated):
* platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp:
(WebCore::TextureMapperPlatformLayerBuffer::clone):
* platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
(WebCore::TextureMapperPlatformLayerProxy::activateOnCompositingThread):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::updateContentBuffers):
* platform/graphics/texmap/coordinated/TiledBackingStore.cpp:
(WebCore::TiledBackingStore::createTiles):
* platform/graphics/transforms/TransformState.cpp:
(WebCore::TransformState::operator=):
(WebCore::TransformState::applyTransform):
(WebCore::TransformState::setLastPlanarSecondaryQuad):
* platform/graphics/transforms/TransformState.h:
(WebCore::TransformState::setSecondaryQuad):
* platform/graphics/win/FontCacheWin.cpp:
(WebCore::FontCache::createFontPlatformData):
* platform/graphics/win/FontCustomPlatformData.cpp:
(WebCore::createFontCustomPlatformData):
* platform/graphics/win/FontCustomPlatformDataCairo.cpp:
(WebCore::createFontCustomPlatformData):
* platform/graphics/win/FullScreenController.cpp:
(WebCore::FullScreenController::FullScreenController):
(WebCore::FullScreenController::enterFullScreen):
* platform/graphics/win/GraphicsContextCairoWin.cpp:
(WebCore::GraphicsContext::platformInit):
* platform/graphics/win/GraphicsContextDirect2D.cpp:
(WebCore::GraphicsContext::GraphicsContext):
(WebCore::GraphicsContext::platformInit):
* platform/graphics/win/GraphicsContextImplDirect2D.cpp:
(WebCore::GraphicsContextImplDirect2D::createFactory):
(WebCore::m_private):
* platform/graphics/win/GraphicsContextWin.cpp:
(WebCore::GraphicsContext::createWindowsBitmap):
* platform/graphics/win/ImageBufferDirect2D.cpp:
(WebCore::ImageBuffer::ImageBuffer):
* platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
(WebCore::MediaPlayerPrivateMediaFoundation::registerMediaEngine):
(WebCore::MediaPlayerPrivateMediaFoundation::buffered const):
(WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::CustomVideoPresenter):
* platform/graphics/win/WKCAImageQueue.cpp:
(WebCore::WKCAImageQueue::WKCAImageQueue):
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::createForCopyAndPaste):
(WebCore::Pasteboard::createForGlobalSelection):
(WebCore::Pasteboard::createForDragAndDrop):
* platform/gtk/PasteboardHelper.cpp:
(WebCore::PasteboardHelper::writeClipboardContents):
* platform/gtk/RenderThemeGadget.cpp:
(WebCore::RenderThemeGadget::create):
* platform/gtk/RenderThemeWidget.cpp:
(WebCore::RenderThemeWidget::getOrCreate):
(WebCore::RenderThemeScrollbar::RenderThemeScrollbar):
(WebCore::RenderThemeComboBox::RenderThemeComboBox):
* platform/image-decoders/bmp/BMPImageDecoder.cpp:
(WebCore::BMPImageDecoder::decodeHelper):
* platform/image-decoders/gif/GIFImageDecoder.cpp:
(WebCore::GIFImageDecoder::decode):
* platform/image-decoders/gif/GIFImageReader.cpp:
(GIFFrameContext::decode):
(GIFImageReader::addFrameIfNecessary):
* platform/image-decoders/ico/ICOImageDecoder.cpp:
(WebCore::ICOImageDecoder::decodeAtIndex):
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(WebCore::JPEGImageDecoder::decode):
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::decode):
* platform/ios/LegacyTileCache.mm:
(WebCore::LegacyTileCache::LegacyTileCache):
(WebCore::LegacyTileCache::commitScaleChange):
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::createForDragAndDrop):
(WebCore::Pasteboard::createForCopyAndPaste):
* platform/ios/QuickLook.mm:
(WebCore::registerQLPreviewConverterIfNeeded):
* platform/ios/RemoteCommandListenerIOS.mm:
(WebCore::RemoteCommandListener::create):
* platform/ios/ScrollAnimatorIOS.mm:
(WebCore::ScrollAnimator::create):
* platform/libwpe/PasteboardLibWPE.cpp:
(WebCore::Pasteboard::createForCopyAndPaste):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::createForCopyAndPaste):
(WebCore::Pasteboard::createForDragAndDrop):
* platform/mac/RemoteCommandListenerMac.mm:
(WebCore::RemoteCommandListener::create):
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimator::create):
* platform/mediarecorder/MediaRecorderPrivateAVFImpl.cpp:
(WebCore::MediaRecorderPrivateAVFImpl::create):
* platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp:
(WebCore::m_capturer):
(WebCore::GStreamerAudioCaptureSource::GStreamerAudioCaptureSource):
* platform/mediastream/gstreamer/GStreamerMediaStreamSource.cpp:
(WebCore::webkit_media_stream_src_init):
* platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp:
(WebCore::GStreamerVideoCaptureSource::GStreamerVideoCaptureSource):
(WebCore::m_capturer):
* platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
(WebCore::GStreamerVideoEncoderFactory::CreateVideoEncoder):
* platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
(WebCore::BasicPacketSocketFactory::BasicPacketSocketFactory):
(WebCore::initializePeerConnectionFactoryAndThreads):
(WebCore::LibWebRTCProvider::createPeerConnection):
(WebCore::LibWebRTCProvider::certificateGenerator):
* platform/mediastream/libwebrtc/LibWebRTCProviderGStreamer.cpp:
(WebCore::LibWebRTCProviderGStreamer::createDecoderFactory):
(WebCore::LibWebRTCProviderGStreamer::createEncoderFactory):
* platform/mediastream/mac/AudioTrackPrivateMediaStreamCocoa.cpp:
(WebCore::AudioTrackPrivateMediaStreamCocoa::audioSamplesAvailable):
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
(WebCore::MockRealtimeAudioSourceMac::reconfigure):
* platform/mediastream/mac/RealtimeOutgoingVideoSourceCocoa.mm:
(WebCore::RealtimeOutgoingVideoSourceCocoa::convertToYUV):
(WebCore::RealtimeOutgoingVideoSourceCocoa::rotatePixelBuffer):
* platform/mock/RTCNotifiersMock.cpp:
(WebCore::RemoteDataChannelNotifier::fire):
* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::MockMediaPlayerMediaSource::registerMediaEngine):
(WebCore::MockMediaPlayerMediaSource::buffered const):
* platform/network/BlobResourceHandle.cpp:
* platform/network/DataURLDecoder.cpp:
(WebCore::DataURLDecoder::createDecodeTask):
* platform/network/ResourceHandle.cpp:
(WebCore::ResourceHandle::ResourceHandle):
* platform/network/cf/ResourceHandleCFURLConnectionDelegateWithOperationQueue.cpp:
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::willSendRequest):
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveResponse):
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveData):
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFinishLoading):
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didFail):
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::willCacheResponse):
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didReceiveChallenge):
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::didSendBodyData):
(WebCore::ResourceHandleCFURLConnectionDelegateWithOperationQueue::canRespondToProtectionSpace):
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSessionDataTask _restart]):
* platform/network/curl/CookieJarDB.cpp:
(WebCore::CookieJarDB::searchCookies):
(WebCore::CookieJarDB::createPrepareStatement):
* platform/network/curl/CurlCacheManager.cpp:
(WebCore::CurlCacheManager::loadIndex):
(WebCore::CurlCacheManager::didReceiveResponse):
* platform/network/curl/CurlContext.cpp:
(WebCore::CurlContext::CurlContext):
(WebCore::CurlHandle::willSetupSslCtx):
* platform/network/curl/CurlFormDataStream.cpp:
(WebCore::CurlFormDataStream::getPostData):
* platform/network/curl/CurlMultipartHandle.cpp:
(WebCore::CurlMultipartHandle::createIfNeeded):
* platform/network/curl/CurlRequest.cpp:
(WebCore::CurlRequest::runOnMainThread):
(WebCore::CurlRequest::setupTransfer):
* platform/network/curl/CurlRequestScheduler.cpp:
(WebCore::CurlRequestScheduler::workerThread):
* platform/network/curl/ResourceHandleCurl.cpp:
(WebCore::ResourceHandle::delegate):
* platform/network/curl/SocketStreamHandleImplCurl.cpp:
(WebCore::SocketStreamHandleImpl::callOnWorkerThread):
* platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm:
(-[WebCoreResourceHandleAsOperationQueueDelegate callFunctionOnMainThread:]):
* platform/network/soup/DNSResolveQueueSoup.cpp:
(WebCore::DNSResolveQueueSoup::resolve):
* platform/network/soup/NetworkStorageSessionSoup.cpp:
(WebCore::NetworkStorageSession::getCredentialFromPersistentStorage):
* platform/text/BidiResolver.h:
(WebCore::DerivedClass>::appendRunInternal):
* platform/text/LocaleICU.cpp:
(WebCore::Locale::create):
(WebCore::LocaleICU::createLabelVector):
(WebCore::createFallbackMonthLabels):
(WebCore::createFallbackAMPMLabels):
* platform/text/LocaleNone.cpp:
(WebCore::Locale::create):
* platform/text/TextCodecICU.cpp:
(WebCore::TextCodecICU::registerCodecs):
* platform/text/TextCodecLatin1.cpp:
(WebCore::TextCodecLatin1::registerCodecs):
* platform/text/TextCodecReplacement.cpp:
(WebCore::TextCodecReplacement::registerCodecs):
* platform/text/TextCodecUTF16.cpp:
(WebCore::TextCodecUTF16::registerCodecs):
* platform/text/TextCodecUTF8.cpp:
(WebCore::TextCodecUTF8::registerCodecs):
* platform/text/TextCodecUserDefined.cpp:
(WebCore::TextCodecUserDefined::registerCodecs):
* platform/text/mac/LocaleMac.mm:
(WebCore::Locale::create):
* platform/text/win/LocaleWin.cpp:
(WebCore::Locale::create):
* platform/text/win/TextCodecWin.cpp:
(WebCore::newTextCodecWin):
* platform/vr/openvr/VRPlatformManagerOpenVR.cpp:
(WebCore::VRPlatformManagerOpenVR::create):
(WebCore::VRPlatformManagerOpenVR::getVRDisplays):
* platform/win/PasteboardWin.cpp:
(WebCore::Pasteboard::createForCopyAndPaste):
(WebCore::Pasteboard::createForDragAndDrop):
* platform/win/SearchPopupMenuDB.cpp:
(WebCore::SearchPopupMenuDB::createPreparedStatement):
* platform/win/WCDataObject.cpp:
(WebCore::WCDataObject::SetData):
* rendering/CSSFilter.cpp:
(WebCore::CSSFilter::buildReferenceFilter):
* rendering/ComplexLineLayout.cpp:
(WebCore::createRun):
(WebCore::ComplexLineLayout::createRootInlineBox):
(WebCore::ComplexLineLayout::handleTrailingSpaces):
(WebCore::ComplexLineLayout::linkToEndLineIfNeeded):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::create):
(WebCore::FloatingObject::copyToNewContainer const):
(WebCore::FloatingObject::cloneForNewParent const):
(WebCore::FloatingObjects::computePlacedFloatsTree):
* rendering/Grid.cpp:
(WebCore::GridIterator::nextEmptyGridArea):
* rendering/GridBaselineAlignment.cpp:
(WebCore::GridBaselineAlignment::updateBaselineAlignmentContext):
* rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithm::computeFlexFactorUnitSize const):
(WebCore::GridTrackSizingAlgorithm::setup):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::HitTestResult):
(WebCore::HitTestResult::operator=):
(WebCore::HitTestResult::listBasedTestResult const):
(WebCore::HitTestResult::mutableListBasedTestResult):
* rendering/InlineIterator.h:
(WebCore::addPlaceholderRunForIsolatedInline):
* rendering/LayerOverlapMap.cpp:
(WebCore::LayerOverlapMap::pushCompositingContainer):
* rendering/RenderBlock.cpp:
(WebCore::insertIntoTrackedRendererMaps):
(WebCore::PositionedDescendantsMap::addDescendant):
(WebCore::RenderBlock::beginUpdateScrollInfoAfterLayoutTransaction):
(WebCore::ensureBlockRareData):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutInlineChildren):
(WebCore::RenderBlockFlow::layoutLineGridBox):
(WebCore::RenderBlockFlow::createFloatingObjects):
(WebCore::RenderBlockFlow::ensureLineBoxes):
(WebCore::RenderBlockFlow::materializeRareBlockFlowData):
* rendering/RenderBox.cpp:
(WebCore::controlStatesForRenderer):
(WebCore::RenderBox::createInlineBox):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::ensureContinuationChainNode):
* rendering/RenderCounter.cpp:
(WebCore::makeCounterNode):
* rendering/RenderFragmentContainer.cpp:
(WebCore::RenderFragmentContainer::setRenderBoxFragmentInfo):
* rendering/RenderFragmentedFlow.cpp:
(WebCore::RenderFragmentedFlow::containingFragmentMap):
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::push):
(WebCore::RenderGeometryMap::pushView):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeEmptyTracksForAutoRepeat const):
(WebCore::RenderGrid::createEmptyGridAreaAtSpecifiedPositionsOutsideGrid const):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::RenderImage):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::createInlineFlowBox):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateNormalFlowList):
(WebCore::RenderLayer::collectLayers):
(WebCore::RenderLayer::updateTransform):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateAncestorClippingStack):
(WebCore::RenderLayerBacking::startAnimation):
(WebCore::RenderLayerBacking::startTransition):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::RenderLayerCompositor):
(WebCore::RenderLayerCompositor::notifyFlushBeforeDisplayRefresh):
(WebCore::LegacyWebKitScrollingLayerCoordinator::registerAllViewportConstrainedLayers):
* rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::createLayer):
* rendering/RenderLineBreak.cpp:
(WebCore::RenderLineBreak::createInlineBox):
* rendering/RenderMultiColumnFlow.cpp:
(WebCore::RenderMultiColumnFlow::RenderMultiColumnFlow):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::ensureRareData):
* rendering/RenderSnapshottedPlugIn.cpp:
(WebCore::RenderSnapshottedPlugIn::RenderSnapshottedPlugIn):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::styleDidChange):
* rendering/RenderText.cpp:
(WebCore::RenderText::createTextBox):
(WebCore::RenderText::momentarilyRevealLastTypedCharacter):
* rendering/RenderView.cpp:
(WebCore::RenderView::repaintViewRectangle const):
(WebCore::RenderView::compositor):
(WebCore::RenderView::imageQualityController):
(WebCore::RenderView::RepaintRegionAccumulator::RepaintRegionAccumulator):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::placeEllipsis):
* rendering/RootInlineBox.h:
(WebCore::RootInlineBox::appendFloat):
* rendering/SelectionRangeData.cpp:
(WebCore::collect):
(WebCore::SelectionRangeData::collectBounds const):
(WebCore::SelectionRangeData::apply):
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::Layout::runResolver const):
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow):
(WebCore::SimpleLineLayout::generateLineBoxTree):
* rendering/TextAutoSizing.cpp:
(WebCore::TextAutoSizing::addTextNode):
* rendering/line/LineBreaker.cpp:
(WebCore::LineBreaker::skipLeadingWhitespace):
* rendering/shapes/RasterShape.cpp:
(WebCore::RasterShapeIntervals::computeShapeMarginIntervals const):
* rendering/shapes/Shape.cpp:
(WebCore::createInsetShape):
(WebCore::createCircleShape):
(WebCore::createEllipseShape):
(WebCore::createPolygonShape):
(WebCore::Shape::createShape):
(WebCore::Shape::createRasterShape):
(WebCore::Shape::createBoxShape):
* rendering/shapes/ShapeOutsideInfo.h:
* rendering/style/BasicShapes.cpp:
(WebCore::BasicShapePath::blend const):
* rendering/style/ContentData.h:
* rendering/style/FillLayer.cpp:
(WebCore::FillLayer::FillLayer):
(WebCore::FillLayer::operator=):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::clonePtr):
(WebCore::RenderStyle::addCachedPseudoStyle):
(WebCore::RenderStyle::addCustomPaintWatchProperty):
(WebCore::RenderStyle::setContent):
(WebCore::RenderStyle::accessCounterDirectives):
(WebCore::RenderStyle::ensureAnimations):
(WebCore::RenderStyle::ensureTransitions):
* rendering/style/SVGRenderStyleDefs.cpp:
(WebCore::StyleShadowSVGData::StyleShadowSVGData):
* rendering/style/ShadowData.cpp:
(WebCore::ShadowData::ShadowData):
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
* rendering/svg/RenderSVGImage.cpp:
(WebCore::RenderSVGImage::RenderSVGImage):
* rendering/svg/RenderSVGInline.cpp:
(WebCore::RenderSVGInline::createInlineFlowBox):
* rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::createTextBox):
* rendering/svg/RenderSVGResourceFilter.cpp:
(WebCore::RenderSVGResourceFilter::buildPrimitives const):
(WebCore::RenderSVGResourceFilter::applyResource):
* rendering/svg/RenderSVGResourceGradient.cpp:
(WebCore::RenderSVGResourceGradient::applyResource):
* rendering/svg/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::applyResource):
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::buildPattern):
* rendering/svg/RenderSVGShape.cpp:
(WebCore::RenderSVGShape::updateShapeFromElement):
* rendering/svg/SVGResources.cpp:
(WebCore::SVGResources::setClipper):
(WebCore::SVGResources::setFilter):
(WebCore::SVGResources::setMarkerStart):
(WebCore::SVGResources::setMarkerMid):
(WebCore::SVGResources::setMarkerEnd):
(WebCore::SVGResources::setMasker):
(WebCore::SVGResources::setFill):
(WebCore::SVGResources::setStroke):
* rendering/svg/SVGResourcesCache.cpp:
(WebCore::SVGResourcesCache::addResourcesFromRenderer):
* rendering/svg/SVGTextMetricsBuilder.cpp:
(WebCore::SVGTextMetricsBuilder::initializeMeasurementWithTextRenderer):
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::RenderTreeBuilder):
* rendering/updating/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::RenderTreeUpdater):
* style/StyleInvalidator.cpp:
(WebCore::Style::Invalidator::Invalidator):
* style/StyleRelations.cpp:
(WebCore::Style::commitRelationsToRenderStyle):
* style/StyleScope.cpp:
(WebCore::Style::Scope::resolver):
(WebCore::Style::Scope::activeStyleSheetsContains const):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolve):
* svg/SVGDocumentExtensions.cpp:
(WebCore::SVGDocumentExtensions::SVGDocumentExtensions):
(WebCore::SVGDocumentExtensions::addPendingResource):
(WebCore::SVGDocumentExtensions::addElementReferencingTarget):
* svg/SVGElement.cpp:
(WebCore::SVGElement::SVGElement):
(WebCore::SVGElement::ensureSVGRareData):
* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::supplementalTransform):
* svg/SVGPathByteStream.h:
(WebCore::SVGPathByteStream::copy const):
* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::schedule):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::dataChanged):
* svg/properties/SVGAnimatedDecoratedProperty.h:
(WebCore::SVGAnimatedDecoratedProperty::create):
* svg/properties/SVGAnimatedPropertyAnimatorImpl.h:
* svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h:
* svg/properties/SVGDecoratedEnumeration.h:
(WebCore::SVGDecoratedEnumeration::create):
* svg/properties/SVGPrimitivePropertyAnimator.h:
(WebCore::SVGPrimitivePropertyAnimator::create):
* svg/properties/SVGValuePropertyAnimatorImpl.h:
* svg/properties/SVGValuePropertyListAnimatorImpl.h:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::from):
* testing/Internals.cpp:
(WebCore::InspectorStubFrontend::InspectorStubFrontend):
(WebCore::Internals::Internals):
(WebCore::Internals::enableMockSpeechSynthesizer):
(WebCore::Internals::openDummyInspectorFrontend):
(WebCore::Internals::setPrinting):
(WebCore::Internals::initializeMockCDM):
(WebCore::Internals::queueMicroTask):
* testing/LegacyMockCDM.cpp:
(WebCore::LegacyMockCDM::createSession):
* testing/MockCDMFactory.cpp:
(WebCore::MockCDMFactory::createCDM):
* testing/MockContentFilter.cpp:
(WebCore::MockContentFilter::create):
* testing/MockGamepadProvider.cpp:
(WebCore::MockGamepadProvider::setMockGamepadDetails):
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::messageWithTypeAndLevel):
* workers/WorkerEventQueue.cpp:
(WebCore::WorkerEventQueue::enqueueEvent):
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::WorkerGlobalScope):
(WebCore::WorkerGlobalScope::addMessage):
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::WorkerMessagingProxy):
(WebCore::WorkerMessagingProxy::postMessageToWorkerGlobalScope):
* workers/WorkerRunLoop.cpp:
(WebCore::WorkerRunLoop::WorkerRunLoop):
(WebCore::WorkerRunLoop::postTaskAndTerminate):
(WebCore::WorkerRunLoop::postTaskForMode):
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::loadAsynchronously):
(WebCore::WorkerScriptLoader::createResourceRequest):
* workers/WorkerThread.cpp:
(WebCore::WorkerThread::WorkerThread):
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::ready):
(WebCore::ServiceWorkerContainer::addRegistration):
(WebCore::ServiceWorkerContainer::removeRegistration):
(WebCore::ServiceWorkerContainer::updateRegistration):
(WebCore::ServiceWorkerContainer::getRegistration):
(WebCore::ServiceWorkerContainer::getRegistrations):
* workers/service/context/SWContextManager.cpp:
(WebCore::SWContextManager::terminateWorker):
* workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
(WebCore::ServiceWorkerThreadProxy::createBlobLoader):
* workers/service/server/RegistrationDatabase.cpp:
(WebCore::RegistrationDatabase::openSQLiteDatabase):
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::addRegistrationFromStore):
(WebCore::SWServer::SWServer):
(WebCore::SWServer::scheduleJob):
(WebCore::SWServer::unregisterServiceWorkerClient):
* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::runRegisterJob):
* worklets/PaintWorkletGlobalScope.cpp:
(WebCore::PaintWorkletGlobalScope::registerPaint):
* worklets/WorkletConsoleClient.cpp:
(WebCore::WorkletConsoleClient::messageWithTypeAndLevel):
* worklets/WorkletGlobalScope.cpp:
(WebCore::WorkletGlobalScope::WorkletGlobalScope):
(WebCore::WorkletGlobalScope::addConsoleMessage):
* worklets/WorkletScriptController.cpp:
(WebCore::WorkletScriptController::initScriptWithSubclass):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::upload):
* xml/XPathFunctions.cpp:
* xml/XPathPredicate.cpp:
(WebCore::XPath::evaluatePredicate):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::loadChildSheet):
* xml/parser/XMLDocumentParser.cpp:
(WebCore::XMLDocumentParser::handleError):
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::PendingCallbacks::appendStartElementNSCallback):
(WebCore::PendingCallbacks::appendEndElementNSCallback):
(WebCore::PendingCallbacks::appendCharactersCallback):
(WebCore::PendingCallbacks::appendProcessingInstructionCallback):
(WebCore::PendingCallbacks::appendCDATABlockCallback):
(WebCore::PendingCallbacks::appendCommentCallback):
(WebCore::PendingCallbacks::appendInternalSubsetCallback):
(WebCore::PendingCallbacks::appendErrorCallback):
(WebCore::XMLDocumentParser::XMLDocumentParser):
(WebCore::XMLDocumentParser::doEnd):
Source/WebCore/PAL:
Reviewed by Geoffrey Garen.
* pal/crypto/openssl/CryptoDigestOpenSSL.cpp:
(PAL::CryptoDigestContextImpl::create):
* pal/system/ClockGeneric.cpp:
(PAL::Clock::create):
* pal/system/mac/ClockCM.mm:
(Clock::create):
Source/WebDriver:
Reviewed by Geoffrey Garen.
* WebDriverService.cpp:
(WebDriver::WebDriverService::connectToBrowser):
* glib/SessionHostGlib.cpp:
(WebDriver::SessionHost::launchBrowser):
(WebDriver::SessionHost::sendMessageToBackend):
Source/WebKit:
Reviewed by Geoffrey Garen.
* NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp:
(WebKit::ResourceLoadStatisticsPersistentStorage::startMonitoringDisk):
(WebKit::ResourceLoadStatisticsPersistentStorage::monitorDirectoryForNewStatistics):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
* NetworkProcess/CustomProtocols/soup/LegacyCustomProtocolManagerSoup.cpp:
* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::startDownload):
(WebKit::DownloadManager::convertNetworkLoadToDownload):
(WebKit::DownloadManager::resumeDownload):
* NetworkProcess/Downloads/DownloadMap.cpp:
(WebKit::DownloadMap::add):
* NetworkProcess/Downloads/PendingDownload.cpp:
(WebKit::PendingDownload::PendingDownload):
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::establishSWServerConnection):
* NetworkProcess/NetworkContentRuleListManager.cpp:
(WebKit::NetworkContentRuleListManager::addContentRuleLists):
* NetworkProcess/NetworkDataTaskBlob.cpp:
(WebKit::NetworkDataTaskBlob::NetworkDataTaskBlob):
(WebKit::NetworkDataTaskBlob::download):
* NetworkProcess/NetworkHTTPSUpgradeChecker.cpp:
(WebKit::NetworkHTTPSUpgradeChecker::NetworkHTTPSUpgradeChecker):
* NetworkProcess/NetworkLoad.cpp:
(WebKit::NetworkLoad::didReceiveResponse):
* NetworkProcess/NetworkLoadChecker.cpp:
(WebKit::NetworkLoadChecker::checkCORSRequestWithPreflight):
(WebKit::NetworkLoadChecker::contentSecurityPolicy):
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::switchToNewTestingSession):
(WebKit::NetworkProcess::ensureSession):
(WebKit::NetworkProcess::swServerForSession):
(WebKit::NetworkProcess::initializeQuotaUsers):
(WebKit::NetworkProcess::storageQuotaManager):
* NetworkProcess/NetworkProcess.h:
(WebKit::NetworkProcess::addSupplement):
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::m_shouldCaptureExtraNetworkLoadMetrics):
(WebKit::NetworkResourceLoader::startNetworkLoad):
* NetworkProcess/NetworkSocketChannel.cpp:
(WebKit::NetworkSocketChannel::create):
* NetworkProcess/PreconnectTask.cpp:
* NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
(WebKit::LocalStorageDatabase::scheduleDatabaseUpdate):
* NetworkProcess/WebStorage/LocalStorageNamespace.cpp:
(WebKit::LocalStorageNamespace::getOrCreateStorageArea):
* NetworkProcess/WebStorage/SessionStorageNamespace.cpp:
(WebKit::SessionStorageNamespace::getOrCreateStorageArea):
* NetworkProcess/WebStorage/StorageArea.cpp:
(WebKit::StorageArea::clone const):
* NetworkProcess/WebStorage/StorageManager.cpp:
(WebKit::StorageManager::createSessionStorageNamespace):
(WebKit::StorageManager::getOrCreateLocalStorageNamespace):
(WebKit::StorageManager::getOrCreateTransientLocalStorageNamespace):
(WebKit::StorageManager::getOrCreateSessionStorageNamespace):
* NetworkProcess/WebStorage/StorageManagerSet.cpp:
(WebKit::StorageManagerSet::add):
* NetworkProcess/WebStorage/TransientLocalStorageNamespace.cpp:
(WebKit::TransientLocalStorageNamespace::getOrCreateStorageArea):
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::Cache):
(WebKit::NetworkCache::Cache::makeEntry):
(WebKit::NetworkCache::Cache::makeRedirectEntry):
(WebKit::NetworkCache::Cache::update):
* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::decodeStorageRecord):
* NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
(WebKit::NetworkCache::SpeculativeLoad::SpeculativeLoad):
* NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
(WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::registerSubresourceLoad):
(WebKit::NetworkCache::SpeculativeLoadManager::retrieve):
(WebKit::NetworkCache::SpeculativeLoadManager::addPreloadedEntry):
(WebKit::NetworkCache::SpeculativeLoadManager::satisfyPendingRequests):
(WebKit::NetworkCache::SpeculativeLoadManager::revalidateSubresource):
(WebKit::NetworkCache::SpeculativeLoadManager::startSpeculativeRevalidation):
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::synchronize):
(WebKit::NetworkCache::Storage::readRecord):
(WebKit::NetworkCache::retrieveFromMemory):
(WebKit::NetworkCache::Storage::retrieve):
(WebKit::NetworkCache::Storage::store):
(WebKit::NetworkCache::Storage::traverse):
* NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp:
(WebKit::NetworkCache::SubresourcesEntry::decodeStorageRecord):
* NetworkProcess/cache/PrefetchCache.cpp:
(WebKit::PrefetchCache::store):
(WebKit::PrefetchCache::storeRedirect):
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::platformCreateDefaultStorageSession const):
(WebKit::NetworkProcess::networkHTTPSUpgradeChecker):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:dataTask:didBecomeDownloadTask:]):
(WebKit::NetworkSessionCocoa::create):
(WebKit::NetworkSessionCocoa::createWebSocketTask):
* NetworkProcess/curl/NetworkProcessCurl.cpp:
(WebKit::NetworkProcess::platformCreateDefaultStorageSession const):
* NetworkProcess/curl/NetworkSessionCurl.h:
* NetworkProcess/ios/NetworkConnectionToWebProcessIOS.mm:
(WebKit::NetworkConnectionToWebProcess::paymentCoordinator):
(WebKit::NetworkConnectionToWebProcess::paymentCoordinatorAuthorizationPresenter):
* NetworkProcess/soup/NetworkDataTaskSoup.cpp:
(WebKit::NetworkDataTaskSoup::download):
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::NetworkProcess::platformCreateDefaultStorageSession const):
* NetworkProcess/soup/NetworkSessionSoup.cpp:
(WebKit::NetworkSessionSoup::NetworkSessionSoup):
(WebKit::NetworkSessionSoup::createWebSocketTask):
* NetworkProcess/soup/NetworkSessionSoup.h:
* NetworkProcess/soup/WebKitSoupRequestInputStream.cpp:
(webkitSoupRequestInputStreamReadAsync):
* NetworkProcess/webrtc/NetworkMDNSRegister.cpp:
(WebKit::NetworkMDNSRegister::registerMDNSName):
* NetworkProcess/webrtc/NetworkRTCMonitor.cpp:
(WebKit::NetworkRTCMonitor::startUpdating):
* NetworkProcess/webrtc/NetworkRTCProvider.cpp:
(WebKit::NetworkRTCProvider::NetworkRTCProvider):
(WebKit::NetworkRTCProvider::createSocket):
(WebKit::NetworkRTCProvider::wrapNewTCPConnection):
* Platform/IPC/Connection.cpp:
(IPC::Connection::dispatchWorkQueueMessageReceiverMessage):
(IPC::Connection::createSyncMessageEncoder):
(IPC::Connection::enableIncomingMessagesThrottling):
(IPC::Connection::dispatchSyncMessage):
* Platform/IPC/Connection.h:
(IPC::Connection::send):
(IPC::Connection::sendWithAsyncReply):
* Platform/IPC/Decoder.cpp:
(IPC::Decoder::unwrapForTesting):
* Platform/IPC/HandleMessage.h:
(IPC::handleMessageAsync):
* Platform/IPC/MessageSender.h:
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::ConnectionTerminationWatchdog::ConnectionTerminationWatchdog):
(IPC::Connection::open):
(IPC::createMessageDecoder):
(IPC::Connection::receiveSourceEventHandler):
* Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::processMessage):
(IPC::Connection::sendOutputMessage):
* Platform/IPC/win/ConnectionWin.cpp:
(IPC::Connection::readEventHandler):
* Platform/mac/LayerHostingContext.mm:
(WebKit::LayerHostingContext::createForPort):
(WebKit::LayerHostingContext::createForExternalHostingProcess):
(WebKit::LayerHostingContext::createForExternalPluginHostingProcess):
* PluginProcess/WebProcessConnection.cpp:
(WebKit::WebProcessConnection::createPluginInternal):
* Shared/API/APIURL.h:
(API::URL::create):
(API::URL::parseURLIfNecessary const):
* Shared/API/Cocoa/RemoteObjectInvocation.mm:
(WebKit::RemoteObjectInvocation::decode):
* Shared/API/Cocoa/_WKRemoteObjectRegistry.mm:
(-[_WKRemoteObjectRegistry _initWithWebPage:]):
(-[_WKRemoteObjectRegistry _initWithWebPageProxy:]):
(-[_WKRemoteObjectRegistry _sendInvocation:interface:]):
* Shared/API/glib/WebKitContextMenuItem.cpp:
(webkitContextMenuItemCreate):
(webkit_context_menu_item_new):
(webkit_context_menu_item_new_from_gaction):
(webkit_context_menu_item_new_from_stock_action):
(webkit_context_menu_item_new_from_stock_action_with_label):
(webkit_context_menu_item_new_with_submenu):
(webkit_context_menu_item_new_separator):
* Shared/ApplePay/mac/WebPaymentCoordinatorProxyMac.mm:
(WebKit::WebPaymentCoordinatorProxy::platformShowPaymentUI):
* Shared/Cocoa/SandboxExtensionCocoa.mm:
(WebKit::SandboxExtension::Handle::decode):
* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::texmapLayer):
(WebKit::CoordinatedGraphicsScene::ensureRootLayer):
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::ThreadedCompositor):
* Shared/Plugins/NPRemoteObjectMap.cpp:
(WebKit::NPRemoteObjectMap::registerNPObject):
* Shared/Plugins/Netscape/NetscapePluginModule.cpp:
(WebKit::NetscapePluginModule::tryLoad):
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
(WebKit::RemoteLayerTreeTransaction::decode):
* Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
(WebKit::RemoteScrollingCoordinatorTransaction::decode):
* Shared/cairo/ShareableBitmapCairo.cpp:
(WebKit::ShareableBitmap::createGraphicsContext):
* Shared/cg/ShareableBitmapCG.cpp:
(WebKit::ShareableBitmap::createGraphicsContext):
* Shared/win/ShareableBitmapDirect2D.cpp:
(WebKit::ShareableBitmap::createGraphicsContext):
* UIProcess/API/APIHTTPCookieStore.cpp:
(API::HTTPCookieStore::registerObserver):
* UIProcess/API/C/WKContext.cpp:
(WKContextSetInjectedBundleClient):
(WKContextSetHistoryClient):
(WKContextSetDownloadClient):
* UIProcess/API/C/WKGeolocationManager.cpp:
(WKGeolocationManagerSetProvider):
* UIProcess/API/C/WKNotificationManager.cpp:
(WKNotificationManagerSetProvider):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageContextMenuClient):
(WKPageSetPageDiagnosticLoggingClient):
(WKPageSetPageFindClient):
(WKPageSetPageFindMatchesClient):
(WKPageSetPageFormClient):
(WKPageSetPageLoaderClient):
(WKPageSetPagePolicyClient):
(WKPageSetPageUIClient):
(WKPageSetPageStateClient):
* UIProcess/API/C/mac/WKPagePrivateMac.mm:
(-[WKObservablePageState initWithPage:]):
* UIProcess/API/C/wpe/WKView.cpp:
(WKViewSetViewClient):
* UIProcess/API/Cocoa/WKBrowsingContextController.mm:
(-[WKBrowsingContextController _initWithPageRef:]):
* UIProcess/API/Cocoa/WKHTTPCookieStore.mm:
(-[WKHTTPCookieStore addObserver:]):
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _setDownloadDelegate:]):
(-[WKProcessPool _setAutomationDelegate:]):
* UIProcess/API/Cocoa/WKUserContentController.mm:
(-[WKUserContentController addScriptMessageHandler:name:]):
(-[WKUserContentController _addScriptMessageHandler:name:userContentWorld:]):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView setAllowsBackForwardNavigationGestures:]):
(-[WKWebView _setInputDelegate:]):
* UIProcess/API/Cocoa/_WKAutomationSession.mm:
(-[_WKAutomationSession setDelegate:]):
* UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
(-[_WKRemoteWebInspectorViewController init]):
* UIProcess/API/glib/IconDatabase.cpp:
(WebKit::readySQLiteStatement):
* UIProcess/API/glib/WebKitAutomationSession.cpp:
(webkitAutomationSessionConstructed):
* UIProcess/API/glib/WebKitContextMenuClient.cpp:
(attachContextMenuClientToView):
* UIProcess/API/glib/WebKitCustomProtocolManagerClient.cpp:
(attachCustomProtocolManagerClientToContext):
* UIProcess/API/glib/WebKitDownloadClient.cpp:
(attachDownloadClientToContext):
* UIProcess/API/glib/WebKitFaviconDatabase.cpp:
(webkitFaviconDatabaseOpen):
* UIProcess/API/glib/WebKitFindController.cpp:
(webkitFindControllerConstructed):
* UIProcess/API/glib/WebKitFormClient.cpp:
(attachFormClientToView):
* UIProcess/API/glib/WebKitGeolocationManager.cpp:
(webkitGeolocationManagerCreate):
* UIProcess/API/glib/WebKitIconLoadingClient.cpp:
(attachIconLoadingClientToView):
* UIProcess/API/glib/WebKitInjectedBundleClient.cpp:
(attachInjectedBundleClientToContext):
* UIProcess/API/glib/WebKitNotificationProvider.cpp:
(WebKitNotificationProvider::WebKitNotificationProvider):
* UIProcess/API/glib/WebKitUIClient.cpp:
(attachUIClientToView):
* UIProcess/API/glib/WebKitUserContentManager.cpp:
(webkit_user_content_manager_register_script_message_handler):
(webkit_user_content_manager_register_script_message_handler_in_world):
* UIProcess/API/glib/WebKitWebContext.cpp:
(webkitWebContextConstructed):
(webkit_web_context_set_automation_allowed):
* UIProcess/API/glib/WebKitWebView.cpp:
(webkitWebViewConstructed):
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::createDrawingAreaProxy):
* UIProcess/API/gtk/WebKitEmojiChooser.cpp:
(webkitEmojiChooserSetupEmojiSections):
* UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp:
(WebKit::RemoteInspectorProtocolHandler::handleRequest):
* UIProcess/API/gtk/WebKitWebInspector.cpp:
(webkitWebInspectorCreate):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseConstructed):
(webkitWebViewBaseGestureController):
(webkitWebViewBaseDragAndDropHandler):
(webkitWebViewBaseDidRelaunchWebProcess):
* UIProcess/API/mac/WKView.mm:
(-[WKView maybeInstallIconLoadingClient]):
(-[WKView initWithFrame:processPool:configuration:]):
* UIProcess/API/wpe/PageClientImpl.cpp:
(WebKit::PageClientImpl::PageClientImpl):
(WebKit::PageClientImpl::createDrawingAreaProxy):
* UIProcess/API/wpe/WPEView.cpp:
(WKWPE::View::View):
(WKWPE::View::setClient):
* UIProcess/API/wpe/qt/WPEQtView.cpp:
(WPEQtView::notifyLoadChangedCallback):
(WPEQtView::notifyLoadFailedCallback):
(WPEQtView::runJavaScript):
* UIProcess/API/wpe/qt/WPEQtViewBackend.cpp:
(WPEQtViewBackend::create):
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::WebAutomationSession):
* UIProcess/AuxiliaryProcessProxy.h:
(WebKit::AuxiliaryProcessProxy::send):
* UIProcess/Cocoa/IconLoadingDelegate.mm:
(WebKit::IconLoadingDelegate::createIconLoadingClient):
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::createContextMenuClient):
(WebKit::UIDelegate::createUIClient):
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
(WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitialize):
(WebKit::WebProcessPool::startDisplayLink):
* UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::processWasUnexpectedlyUnsuspended):
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::createDrawingAreaProxy):
(WebKit::WebViewImpl::setTextIndicator):
(WebKit::WebViewImpl::ensureGestureController):
* UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp:
(WebKit::DrawingAreaProxyCoordinatedGraphics::incorporateUpdate):
(WebKit::DrawingAreaProxyCoordinatedGraphics::dispatchAfterEnsuringDrawing):
* UIProcess/DeviceIdHashSaltStorage.cpp:
(WebKit::DeviceIdHashSaltStorage::getDataFromDecoder const):
(WebKit::DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall):
* UIProcess/Downloads/DownloadProxyMap.cpp:
(WebKit::DownloadProxyMap::createDownloadProxy):
* UIProcess/Gamepad/UIGamepadProvider.cpp:
(WebKit::UIGamepadProvider::setInitialConnectedGamepads):
(WebKit::UIGamepadProvider::platformGamepadConnected):
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::createDownloadProxy):
(WebKit::NetworkProcessProxy::takeUploadAssertion):
* UIProcess/Notifications/WebNotificationManagerProxy.cpp:
(WebKit::WebNotificationManagerProxy::WebNotificationManagerProxy):
(WebKit::WebNotificationManagerProxy::setProvider):
* UIProcess/Plugins/unix/PluginProcessProxyUnix.cpp:
(WebKit::pluginRequiresGtk2):
* UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottler::didConnectToProcess):
* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy):
(WebKit::RemoteLayerTreeDrawingAreaProxy::initializeDebugIndicator):
* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::makeNode):
* UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm:
(WebKit::RemoteLayerTreeNode::createWithPlainLayer):
* UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:
(WebKit::RemoteLayerTreeHost::makeNode):
* UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
(WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::commitStateBeforeChildren):
* UIProcess/RemoteLayerTree/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::ScrollingTreeOverflowScrollingNodeIOS):
* UIProcess/RemoteLayerTree/mac/ScrollingTreeFrameScrollingNodeRemoteMac.cpp:
(WebKit::ScrollingTreeFrameScrollingNodeRemoteMac::ScrollingTreeFrameScrollingNodeRemoteMac):
* UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.cpp:
(WebKit::ScrollingTreeOverflowScrollingNodeRemoteMac::ScrollingTreeOverflowScrollingNodeRemoteMac):
* UIProcess/WebAuthentication/Cocoa/HidService.mm:
(WebKit::HidService::deviceAdded):
* UIProcess/WebGeolocationManagerProxy.cpp:
(WebKit::WebGeolocationManagerProxy::WebGeolocationManagerProxy):
(WebKit::WebGeolocationManagerProxy::setProvider):
* UIProcess/WebMediaSessionFocusManager.cpp:
(WebKit::WebMediaSessionFocusManager::setFocusedMediaElement):
* UIProcess/WebPageInspectorController.cpp:
(WebKit::WebPageInspectorController::WebPageInspectorController):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::m_resetRecentCrashCountTimer):
(WebKit::WebPageProxy::setFormClient):
(WebKit::WebPageProxy::setUIClient):
(WebKit::WebPageProxy::setIconLoadingClient):
(WebKit::WebPageProxy::setFindClient):
(WebKit::WebPageProxy::setFindMatchesClient):
(WebKit::WebPageProxy::setContextMenuClient):
(WebKit::WebPageProxy::setInjectedBundleClient):
(WebKit::WebPageProxy::suspendCurrentPageIfPossible):
(WebKit::WebPageProxy::didAttachToRunningProcess):
(WebKit::WebPageProxy::setDrawingArea):
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::loadData):
(WebKit::WebPageProxy::handleWheelEvent):
(WebKit::WebPageProxy::processNextQueuedWheelEvent):
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::setFullscreenClient):
(WebKit::WebPageProxy::userMediaPermissionRequestManager):
(WebKit::WebPageProxy::setScrollPerformanceDataCollectionEnabled):
(WebKit::WebPageProxy::speechSynthesisData):
* UIProcess/WebProcessCache.cpp:
(WebKit::WebProcessCache::addProcessIfPossible):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::WebProcessPool):
(WebKit::WebProcessPool::setInjectedBundleClient):
(WebKit::WebProcessPool::setHistoryClient):
(WebKit::WebProcessPool::setDownloadClient):
(WebKit::WebProcessPool::setAutomationClient):
(WebKit::WebProcessPool::setLegacyCustomProtocolManagerClient):
(WebKit::WebProcessPool::ensureNetworkProcess):
(WebKit::WebProcessPool::didCollectPrewarmInformation):
(WebKit::WebProcessPool::setWebProcessHasUploads):
(WebKit::WebProcessPool::setWebProcessIsPlayingAudibleMedia):
* UIProcess/WebProcessProxy.cpp:
* UIProcess/cairo/BackingStoreCairo.cpp:
(WebKit::BackingStore::createBackend):
* UIProcess/glib/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::inspect):
* UIProcess/gtk/AcceleratedBackingStoreWayland.cpp:
(WebKit::AcceleratedBackingStoreWayland::checkRequirements):
* UIProcess/gtk/DragAndDropHandler.cpp:
(WebKit::DragAndDropHandler::dragDataSelection):
* UIProcess/gtk/WaylandCompositor.cpp:
(WebKit::WaylandCompositor::initializeEGL):
* UIProcess/ios/EditableImageController.mm:
(WebKit::EditableImageController::ensureEditableImage):
* UIProcess/ios/WKApplicationStateTrackingView.mm:
(-[WKApplicationStateTrackingView didMoveToWindow]):
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _commonInitializationWithProcessPool:configuration:]):
(-[WKContentView initWithFrame:processPool:configuration:webView:]):
(-[WKContentView _createDrawingAreaProxy:]):
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView becomeFirstResponderForWebView]):
(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::elementDidFocus):
(WebKit::WebPageProxy::paymentCoordinatorAuthorizationPresenter):
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::PageClientImpl):
* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController initWithWindow:webView:page:]):
* UIProcess/mac/WKTextFinderClient.mm:
(-[WKTextFinderClient initWithPage:view:usePlatformFindUI:]):
* UIProcess/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::inspect):
* UIProcess/socket/RemoteInspectorProtocolHandler.cpp:
(WebKit::RemoteInspectorProtocolHandler::platformStartTask):
* UIProcess/win/BackingStoreDirect2D.cpp:
(WebKit::BackingStore::createBackend):
* UIProcess/win/PageClientImpl.cpp:
(WebKit::PageClientImpl::createDrawingAreaProxy):
* UIProcess/win/WebView.cpp:
(WebKit::WebView::WebView):
* WebProcess/Gamepad/WebGamepadProvider.cpp:
(WebKit::WebGamepadProvider::setInitialGamepads):
(WebKit::WebGamepadProvider::gamepadConnected):
* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleSetClient):
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageSetContextMenuClient):
(WKBundlePageSetEditorClient):
(WKBundlePageSetFormClient):
(WKBundlePageSetPageLoaderClient):
(WKBundlePageSetResourceLoadClient):
(WKBundlePageSetUIClient):
* WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
(WKBundlePageOverlayCreate):
* WebProcess/InjectedBundle/API/c/mac/WKBundlePageBannerMac.mm:
(WKBundlePageBannerCreateBannerWithCALayer):
* WebProcess/InjectedBundle/API/glib/DOM/DOMObjectCache.cpp:
(WebKit::getOrCreateDOMObjectCacheFrameObserver):
(WebKit::DOMObjectCache::put):
* WebProcess/InjectedBundle/API/glib/WebKitExtensionManager.cpp:
(WebKit::WebKitExtensionManager::initialize):
* WebProcess/InjectedBundle/API/glib/WebKitWebEditor.cpp:
(webkitWebEditorCreate):
* WebProcess/InjectedBundle/API/glib/WebKitWebExtension.cpp:
(webkitWebExtensionCreate):
* WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp:
(webkitFrameGetOrCreate):
(webkitWebPageCreate):
* WebProcess/InjectedBundle/API/mac/WKDOMTextIterator.mm:
(-[WKDOMTextIterator initWithRange:]):
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
(-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]):
(-[WKWebProcessPlugInBrowserContextController _setEditingDelegate:]):
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::InjectedBundle):
(WebKit::InjectedBundle::setClient):
* WebProcess/Network/WebSocketChannel.cpp:
(WebKit::PendingMessage::PendingMessage):
(WebKit::WebSocketChannel::send):
* WebProcess/Network/webrtc/LibWebRTCProvider.cpp:
(WebKit::LibWebRTCProvider::createPeerConnection):
(WebKit::LibWebRTCProvider::createSocketFactory):
* WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
(WebKit::LibWebRTCSocketFactory::createServerTcpSocket):
(WebKit::LibWebRTCSocketFactory::createUdpSocket):
(WebKit::LibWebRTCSocketFactory::createClientTcpSocket):
(WebKit::LibWebRTCSocketFactory::createNewConnectionSocket):
(WebKit::LibWebRTCSocketFactory::createAsyncResolver):
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::PluginDestructionProtector::PluginDestructionProtector):
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::scheduleTimer):
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::deliverData):
* WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp:
(WebKit::NetscapePluginX11::create):
* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::initialize):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::createWebEvent const):
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::installServiceWorker):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::createColorChooser):
(WebKit::WebChromeClient::createDataListSuggestionPicker):
* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::showPaintRect):
* WebProcess/WebCoreSupport/WebPasteboardOverrides.cpp:
(WebKit::WebPasteboardOverrides::addOverride):
* WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp:
(WebKit::DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode):
* WebProcess/WebPage/DrawingArea.cpp:
(WebKit::DrawingArea::create):
* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::ensureBackingStore):
(WebKit::PlatformCALayerRemote::setTransform):
(WebKit::PlatformCALayerRemote::setSublayerTransform):
(WebKit::PlatformCALayerRemote::setFilters):
(WebKit::PlatformCALayerRemote::setShapeRoundedRect):
* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteTiledBacking.cpp:
(WebKit::PlatformCALayerRemoteTiledBacking::PlatformCALayerRemoteTiledBacking):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::createSubframe):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_textAutoSizingAdjustmentTimer):
(WebKit::WebPage::setInjectedBundleContextMenuClient):
(WebKit::WebPage::setInjectedBundleEditorClient):
(WebKit::WebPage::setInjectedBundleFormClient):
(WebKit::WebPage::setInjectedBundlePageLoaderClient):
(WebKit::WebPage::setInjectedBundleResourceLoadClient):
(WebKit::WebPage::setInjectedBundleUIClient):
(WebKit::WebPage::close):
(WebKit::WebPage::beginPrinting):
* WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
(WebKit::WebPrintOperationGtk::print):
* WebProcess/WebPage/ios/FindControllerIOS.mm:
(WebKit::FindController::updateFindIndicator):
* WebProcess/WebPage/mac/DrawingAreaMac.cpp:
(WebKit::DisplayRefreshMonitorMac::requestRefreshCallback):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::markAllLayersVolatile):
(WebKit::WebProcess::ensureAutomationSessionProxy):
(WebKit::WebProcess::libWebRTCNetwork):
(WebKit::WebProcess::establishWorkerContextConnectionToNetworkProcess):
* WebProcess/WebProcess.h:
(WebKit::WebProcess::addSupplement):
* WebProcess/cocoa/UserMediaCaptureManager.cpp:
(WebKit::UserMediaCaptureManager::Source::Source):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::processTaskStateDidChange):
(WebKit::WebProcess::updateCPUMonitorState):
Source/WebKitLegacy:
Reviewed by Geoffrey Garen.
* Storage/StorageSyncManager.cpp:
(WebCore::StorageSyncManager::StorageSyncManager):
* Storage/StorageThread.cpp:
(WebCore::StorageThread::dispatch):
(WebCore::StorageThread::terminate):
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::StorageTracker):
* WebCoreSupport/NetworkStorageSessionMap.cpp:
(NetworkStorageSessionMap::defaultStorageSession):
(NetworkStorageSessionMap::switchToNewTestingSession):
(NetworkStorageSessionMap::ensureSession):
Source/WebKitLegacy/cf:
Reviewed by Geoffrey Garen.
* WebCoreSupport/WebInspectorClientCF.cpp:
(WebInspectorClient::createFrontendSettings):
Source/WebKitLegacy/ios:
Reviewed by Geoffrey Garen.
* WebCoreSupport/WebFixedPositionContent.mm:
(-[WebFixedPositionContent setViewportConstrainedLayers:stickyContainerMap:]):
Source/WebKitLegacy/mac:
Reviewed by Geoffrey Garen.
* History/WebHistory.mm:
(-[WebHistoryPrivate init]):
* History/WebHistoryItem.mm:
(-[WebHistoryItem initFromDictionaryRepresentation:]):
* Plugins/Hosted/NetscapePluginHostProxy.mm:
(WKPCGetScriptableNPObjectReply):
(WKPCBooleanReply):
(WKPCBooleanAndDataReply):
(WKPCInstantiatePluginReply):
* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyInstance::methodNamed):
(WebKit::ProxyInstance::fieldNamed):
* Plugins/Hosted/WebHostedNetscapePluginView.mm:
(-[WebHostedNetscapePluginView createPlugin]):
* Plugins/WebNetscapePluginEventHandler.mm:
(WebNetscapePluginEventHandler::create):
* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView scheduleTimerWithInterval:repeat:timerFunc:]):
* Storage/WebDatabaseManagerClient.mm:
(DidModifyOriginData::dispatchToMainThread):
* WebCoreSupport/WebFrameLoaderClient.mm:
(addRedirectURL):
(WebFrameLoaderClient::savePlatformDataToCachedFrame):
* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorClient::openLocalFrontend):
* WebView/WebDeviceOrientationProviderMock.mm:
* WebView/WebFrame.mm:
(-[WebFrame _attachScriptDebugger]):
* WebView/WebMediaPlaybackTargetPicker.mm:
(WebMediaPlaybackTargetPicker::create):
* WebView/WebTextIterator.mm:
(-[WebTextIterator initWithRange:]):
* WebView/WebView.mm:
(-[WebView _injectOutlookQuirksScript]):
(-[WebView _commonInitializationWithFrameName:groupName:]):
(+[WebView _addUserScriptToGroup:world:source:url:whitelist:blacklist:injectionTime:injectedFrames:]):
(+[WebView _addUserStyleSheetToGroup:world:source:url:whitelist:blacklist:injectedFrames:]):
(-[WebView _selectionServiceController]):
(-[WebView _setTextIndicator:withLifetime:]):
* WebView/WebViewData.mm:
(WebViewLayerFlushScheduler::WebViewLayerFlushScheduler):
(-[WebViewPrivate init]):
Source/WebKitLegacy/win:
Reviewed by Geoffrey Garen.
* FullscreenVideoController.cpp:
(FullscreenVideoController::FullscreenVideoController):
* Plugins/PluginStream.cpp:
(WebCore::PluginStream::didReceiveData):
* Plugins/PluginView.cpp:
(WebCore::PluginView::load):
* Plugins/PluginViewWin.cpp:
(WebCore::PluginView::wndProc):
* WebCoreSupport/WebChromeClient.cpp:
(WebChromeClient::WebChromeClient):
* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::WebFrameLoaderClient):
(WebFrameLoaderClient::savePlatformDataToCachedFrame):
* WebCoreSupport/WebInspectorClient.cpp:
(WebInspectorClient::openLocalFrontend):
(WebInspectorClient::highlight):
* WebElementPropertyBag.cpp:
(WebElementPropertyBag::WebElementPropertyBag):
* WebHistoryItem.cpp:
(WebHistoryItem::initFromDictionaryRepresentation):
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::createD3DPostProcessingContext):
* WebNotificationCenter.cpp:
(WebNotificationCenter::WebNotificationCenter):
* WebView.cpp:
(WebView::handleMouseEvent):
(WebView::registerEmbeddedViewMIMEType):
(WebView::enterVideoFullscreenForVideoElement):
(WebView::addUserScriptToGroup):
(WebView::addUserStyleSheetToGroup):
(WebView::setAcceleratedCompositing):
Source/WTF:
Reviewed by Geoff Garen.
This patch is second part of bug 200620 patch. I split I split it into three pieces to make roll-out easy.
his part, we convert std::make_unique to WTF::makeUnique or WTF::makeUniqueWithoutFastMallocCheck.
In the third patch, we will add a static_assert to makeUnique, which ensures the given class T is FastMalloced or IsoHeaped.
This patch adds `WTF::makeUnique<T>` and `WTF::makeUniqueWithoutFastMallocCheck<T>` as drop-in replacement for `std::make_unique<T>`.
`WTF::makeUnique<T>` has one additional `static_assert` check which ensures `T` FastMalloc / IsoHeap annotated. If it is not, the
compile error happens.
In this patch, I tried using this everywhere in WebKit as much as possible. And we found that surprisingly many classes are missing
FastMalloc annotation and allocated from system-malloc. Using WTF::makeUnique enforces classes / structs to use FastMalloc.
WTF::makeUniqueWithoutFastMallocCheck is offered for the corner cases. This is identical to std::make_unique. We use this for classes
that are offered by non-WebKit code base, like, zlib. This clear name can make us easily find this allocation is intentionally done
by system-malloc.
We do not take the following direction, `WTF::makeUnique` automatically allocates FastMalloc even if FastMalloc annotation is not attached.
Since default deleter is performing `delete` and this is not what we want for FastMalloced ones, we need to return
std::unique_ptr<T, FastFreeDeleter> for T if T does not have FastMalloc-annotation. Automatically doing this sounds a bit dangerous.
auto pointer = WTF::makeUnique<T>();
// Super dangerous, but sometimes it is required...
auto* rawPointer = pointer.release();
// Passing rawPointer to somewhere, and
delete rawPointer;
The above one becomes invalid because pointer may start requiring non `delete` destroying function.
In the above case, the correct way becomes the following.
rawPointer->~T();
fastFree(rawPointer);
This looks non-intuitive. And having two ways to destroying objects (`delete` or the above one) can be error-prone.
If we have WTF_MAKE_FAST_ALLOCATED for T, we do not need to care about this. "new" and "delete" operators are defined, and C++ way works.
The simple invariant, "makeUnique just does `new` internally. And `delete` operator does `delete`. default deleter is just doing `delete`", is kept.
While we need to annotate many classes with WTF_MAKE_FAST_ALLOCATED, it is one time cost when we add a class.
And, by introducing `WTF::makeUnique<>`, we no longer forget adding this.
makeUnique(...)
static_assert(T is FastMalloced or IsoHeaped);
return make_unique<T>(...)
* benchmarks/LockFairnessTest.cpp:
* benchmarks/LockSpeedTest.cpp:
* wtf/ConcurrentVector.h:
* wtf/CrossThreadTaskHandler.cpp:
(WTF::CrossThreadTaskHandler::taskRunLoop):
* wtf/FilePrintStream.cpp:
(WTF::FilePrintStream::open):
* wtf/Function.h:
(WTF::Function<Out):
* wtf/HashTable.h:
(WTF::KeyTraits>::HashTable):
* wtf/MemoryPressureHandler.cpp:
(WTF::MemoryPressureHandler::setShouldUsePeriodicMemoryMonitor):
* wtf/StdLibExtras.h:
(WTF::makeUnique):
(WTF::makeUniqueWithoutFastMallocCheck):
* wtf/StreamBuffer.h:
(WTF::StreamBuffer::append):
* wtf/UniqueRef.h:
(WTF::makeUniqueRefWithoutFastMallocCheck):
(WTF::makeUniqueRef):
* wtf/glib/RunLoopGLib.cpp:
(WTF::RunLoop::dispatchAfter):
* wtf/text/StringView.cpp:
(WTF::StringView::GraphemeClusters::Iterator::Iterator):
Tools:
Reviewed by Geoffrey Garen.
* DumpRenderTree/TestRunner.cpp:
(addURLToRedirectCallback):
(setWillSendRequestClearHeaderCallback):
(TestRunner::setAccummulateLogsForChannel):
(TestRunner::runUIScript):
(TestRunner::setOpenPanelFiles):
* DumpRenderTree/mac/DumpRenderTree.mm:
(dumpFramesAsText):
* DumpRenderTree/mac/EventSendingController.mm:
(eventPressedMouseButtonsSwizzlerForViewAndEvent):
* DumpRenderTree/win/DRTDataObject.cpp:
(DRTDataObject::SetData):
* DumpRenderTree/win/FrameLoadDelegate.cpp:
(FrameLoadDelegate::FrameLoadDelegate):
* DumpRenderTree/win/UIDelegate.cpp:
(DRTUndoManager::DRTUndoManager):
(UIDelegate::UIDelegate):
(UIDelegate::resetUndoManager):
* TestWebKitAPI/JavaScriptTest.cpp:
(TestWebKitAPI::runJSTest):
* TestWebKitAPI/PlatformUtilities.cpp:
(TestWebKitAPI::Util::toSTD):
* TestWebKitAPI/Tests/WTF/Expected.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/HashCountedSet.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/HashMap.cpp:
(TestWebKitAPI::TEST):
(TestWebKitAPI::testMovingUsingEnsure):
(TestWebKitAPI::testMovingUsingAdd):
* TestWebKitAPI/Tests/WTF/HashSet.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/ListHashSet.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/Lock.cpp:
(TestWebKitAPI::runLockTest):
* TestWebKitAPI/Tests/WTF/ParkingLot.cpp:
* TestWebKitAPI/Tests/WTF/RefCounter.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/ThreadGroup.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/Variant.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/CARingBuffer.cpp:
(TestWebKitAPI::CARingBufferTest::SetUp):
* TestWebKitAPI/Tests/WebCore/CalculationValue.cpp:
(TestWebKitAPI::createTestValue):
* TestWebKitAPI/Tests/WebCore/FidoHidMessageTest.cpp:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/FileMonitor.cpp:
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebCore/curl/Cookies.cpp:
* TestWebKitAPI/Tests/WebKit/CloseFromWithinCreatePage.cpp:
(TestWebKitAPI::createNewPage):
* TestWebKitAPI/Tests/WebKit/ModalAlertsSPI.cpp:
(TestWebKitAPI::createNewPage):
* TestWebKitAPI/Tests/WebKit/TextFieldDidBeginAndEndEditing.cpp:
* TestWebKitAPI/Tests/WebKit/UserMessage.cpp:
(TestWebKitAPI::WebKit2UserMessageRoundTripTest::SetUp):
* TestWebKitAPI/Tests/WebKit/WillLoad.cpp:
(TestWebKitAPI::WebKit2WillLoadTest::SetUp):
* TestWebKitAPI/Tests/WebKit/mac/ForceLightAppearanceInBundle_Bundle.mm:
(TestWebKitAPI::ForceLightAppearanceInBundleTest::didReceiveMessage):
* TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:
(serverCallback):
(testWebViewAuthenticationProxyHTTPS):
* TestWebKitAPI/Tests/WebKitGtk/DOMDOMWindowTest.cpp:
(WebKitDOMDOMWindowTest::create):
* TestWebKitAPI/cocoa/PlatformUtilitiesCocoa.mm:
(TestWebKitAPI::Util::toSTD):
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(applyWorkaroundToAllowWritingAttributedStringsToItemProviders):
(-[TestWKWebView initWithFrame:configuration:addToWindow:]):
* TestWebKitAPI/mac/TestFontOptions.mm:
(-[TestFontOptions initWithFontOptions:]):
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::EventSendingController::callAfterScrollingCompletes):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didCreatePage):
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setOpenPanelFiles):
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
* WebKitTestRunner/StringFunctions.h:
(WTR::toSTD):
(WTR::toWTFString):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):
(WTR::TestController::generatePageConfiguration):
(WTR::TestController::resetStateToConsistentValues):
(WTR::createTestURL):
(WTR::TestController::runTest):
(WTR::TestController::platformCreateWebView):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::runUISideScript):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView):
(WTR::TestController::setDefaultCalendarType):
* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
(WTR::getGDKKeySymForKeyRef):
* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::platformResetStateToConsistentValues):
(WTR::TestController::setKeyboardInputModeIdentifier):
* WebKitTestRunner/mac/EventSenderProxy.mm:
(WTR::EventSenderProxy::mouseDown):
(WTR::EventSenderProxy::mouseUp):
(WTR::EventSenderProxy::mouseMoveTo):
* WebKitTestRunner/wpe/EventSenderProxyWPE.cpp:
(WTR::wpeKeySymForKeyRef):
Canonical link: https://commits.webkit.org/214609@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248846 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-08-19 06:59:40 +00:00
|
|
|
auto sessionHost = makeUnique<SessionHost>(capabilitiesList.takeLast());
|
2017-07-18 07:20:33 +00:00
|
|
|
auto* sessionHostPtr = sessionHost.get();
|
2020-09-30 21:22:57 +00:00
|
|
|
#if USE(INSPECTOR_SOCKET_SERVER)
|
|
|
|
sessionHostPtr->setHostAddress(m_targetAddress, m_targetPort);
|
|
|
|
#endif
|
2021-05-30 16:11:40 +00:00
|
|
|
sessionHostPtr->connectToBrowser([this, capabilitiesList = WTFMove(capabilitiesList), sessionHost = WTFMove(sessionHost), completionHandler = WTFMove(completionHandler)](std::optional<String> error) mutable {
|
2018-01-22 14:04:47 +00:00
|
|
|
if (error) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::SessionNotCreated, makeString("Failed to connect to browser: ", error.value())));
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
createSession(WTFMove(capabilitiesList), WTFMove(sessionHost), WTFMove(completionHandler));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebDriverService::createSession(Vector<Capabilities>&& capabilitiesList, std::unique_ptr<SessionHost>&& sessionHost, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
auto* sessionHostPtr = sessionHost.get();
|
2021-05-30 16:11:40 +00:00
|
|
|
sessionHostPtr->startAutomationSession([this, capabilitiesList = WTFMove(capabilitiesList), sessionHost = WTFMove(sessionHost), completionHandler = WTFMove(completionHandler)](bool capabilitiesDidMatch, std::optional<String> errorMessage) mutable {
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
if (errorMessage) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::UnknownError, errorMessage.value()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!capabilitiesDidMatch) {
|
|
|
|
connectToBrowser(WTFMove(capabilitiesList), WTFMove(completionHandler));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-18 07:20:33 +00:00
|
|
|
RefPtr<Session> session = Session::create(WTFMove(sessionHost));
|
|
|
|
session->createTopLevelBrowsingContext([this, session, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
|
|
|
if (result.isError()) {
|
2017-08-05 09:27:15 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::SessionNotCreated, result.errorMessage()));
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session = WTFMove(session);
|
2017-08-05 09:27:15 +00:00
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto resultObject = JSON::Object::create();
|
2018-06-23 08:39:34 +00:00
|
|
|
resultObject->setString("sessionId"_s, m_session->id());
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto capabilitiesObject = JSON::Object::create();
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
const auto& capabilities = m_session->capabilities();
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
capabilitiesObject->setString("browserName"_s, capabilities.browserName.value_or(emptyString()));
|
|
|
|
capabilitiesObject->setString("browserVersion"_s, capabilities.browserVersion.value_or(emptyString()));
|
|
|
|
capabilitiesObject->setString("platformName"_s, capabilities.platformName.value_or(emptyString()));
|
|
|
|
capabilitiesObject->setBoolean("acceptInsecureCerts"_s, capabilities.acceptInsecureCerts.value_or(false));
|
|
|
|
capabilitiesObject->setBoolean("strictFileInteractability"_s, capabilities.strictFileInteractability.value_or(false));
|
|
|
|
capabilitiesObject->setBoolean("setWindowRect"_s, capabilities.setWindowRect.value_or(true));
|
|
|
|
switch (capabilities.unhandledPromptBehavior.value_or(UnhandledPromptBehavior::DismissAndNotify)) {
|
2018-08-14 06:51:44 +00:00
|
|
|
case UnhandledPromptBehavior::Dismiss:
|
|
|
|
capabilitiesObject->setString("unhandledPromptBehavior"_s, "dismiss");
|
|
|
|
break;
|
|
|
|
case UnhandledPromptBehavior::Accept:
|
|
|
|
capabilitiesObject->setString("unhandledPromptBehavior"_s, "accept");
|
|
|
|
break;
|
|
|
|
case UnhandledPromptBehavior::DismissAndNotify:
|
|
|
|
capabilitiesObject->setString("unhandledPromptBehavior"_s, "dismiss and notify");
|
|
|
|
break;
|
|
|
|
case UnhandledPromptBehavior::AcceptAndNotify:
|
|
|
|
capabilitiesObject->setString("unhandledPromptBehavior"_s, "accept and notify");
|
|
|
|
break;
|
|
|
|
case UnhandledPromptBehavior::Ignore:
|
|
|
|
capabilitiesObject->setString("unhandledPromptBehavior"_s, "ignore");
|
|
|
|
break;
|
2017-08-08 06:43:25 +00:00
|
|
|
}
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
switch (capabilities.pageLoadStrategy.value_or(PageLoadStrategy::Normal)) {
|
2018-01-23 16:21:43 +00:00
|
|
|
case PageLoadStrategy::None:
|
2018-06-23 08:39:34 +00:00
|
|
|
capabilitiesObject->setString("pageLoadStrategy"_s, "none");
|
2018-01-23 16:21:43 +00:00
|
|
|
break;
|
|
|
|
case PageLoadStrategy::Normal:
|
2018-06-23 08:39:34 +00:00
|
|
|
capabilitiesObject->setString("pageLoadStrategy"_s, "normal");
|
2018-01-23 16:21:43 +00:00
|
|
|
break;
|
|
|
|
case PageLoadStrategy::Eager:
|
2018-06-23 08:39:34 +00:00
|
|
|
capabilitiesObject->setString("pageLoadStrategy"_s, "eager");
|
2018-01-23 16:21:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-11-11 15:16:16 +00:00
|
|
|
if (!capabilities.proxy)
|
|
|
|
capabilitiesObject->setObject("proxy"_s, JSON::Object::create());
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto timeoutsObject = JSON::Object::create();
|
2019-12-23 10:42:26 +00:00
|
|
|
if (m_session->scriptTimeout() == std::numeric_limits<double>::infinity())
|
|
|
|
timeoutsObject->setValue("script"_s, JSON::Value::null());
|
|
|
|
else
|
|
|
|
timeoutsObject->setDouble("script"_s, m_session->scriptTimeout());
|
|
|
|
timeoutsObject->setDouble("pageLoad"_s, m_session->pageLoadTimeout());
|
|
|
|
timeoutsObject->setDouble("implicit"_s, m_session->implicitWaitTimeout());
|
2018-06-23 08:39:34 +00:00
|
|
|
capabilitiesObject->setObject("timeouts"_s, WTFMove(timeoutsObject));
|
2018-01-23 16:21:43 +00:00
|
|
|
|
2018-06-23 08:39:34 +00:00
|
|
|
resultObject->setObject("capabilities"_s, WTFMove(capabilitiesObject));
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::success(WTFMove(resultObject)));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::deleteSession(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §8.2 Delete Session.
|
|
|
|
// https://www.w3.org/TR/webdriver/#delete-session
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto sessionID = parameters->getString("sessionId"_s);
|
|
|
|
if (!sessionID) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!m_session || m_session->id() != sessionID) {
|
2017-08-16 11:38:22 +00:00
|
|
|
completionHandler(CommandResult::success());
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
auto session = std::exchange(m_session, nullptr);
|
2018-11-29 09:14:12 +00:00
|
|
|
session->close([session, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2018-01-26 13:20:11 +00:00
|
|
|
// Ignore unknown errors when closing the session if the browser is closed.
|
|
|
|
if (result.isError() && result.errorCode() == CommandResult::ErrorCode::UnknownError && !session->isConnected())
|
|
|
|
completionHandler(CommandResult::success());
|
|
|
|
else
|
|
|
|
completionHandler(WTFMove(result));
|
2017-08-16 11:38:22 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-12-01 09:49:10 +00:00
|
|
|
void WebDriverService::status(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §8.3 Status
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#status
|
|
|
|
auto body = JSON::Object::create();
|
2018-06-23 08:39:34 +00:00
|
|
|
body->setBoolean("ready"_s, !m_session);
|
|
|
|
body->setString("message"_s, m_session ? "A session already exists"_s : "No sessions"_s);
|
2017-12-01 09:49:10 +00:00
|
|
|
completionHandler(CommandResult::success(WTFMove(body)));
|
|
|
|
}
|
|
|
|
|
2018-01-11 10:00:31 +00:00
|
|
|
void WebDriverService::getTimeouts(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §8.4 Get Timeouts.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#get-timeouts
|
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_session->getTimeouts(WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::setTimeouts(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §8.5 Set Timeouts.
|
|
|
|
// https://www.w3.org/TR/webdriver/#set-timeouts
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
2019-12-23 10:42:26 +00:00
|
|
|
auto timeouts = deserializeTimeouts(*parameters, IgnoreUnknownTimeout::Yes);
|
2017-08-05 09:27:15 +00:00
|
|
|
if (!timeouts) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->setTimeouts(timeouts.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::go(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §9.1 Go.
|
|
|
|
// https://www.w3.org/TR/webdriver/#go
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto url = parameters->getString("url"_s);
|
|
|
|
if (!url) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, url = WTFMove(url), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->go(url, WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getCurrentURL(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §9.2 Get Current URL.
|
|
|
|
// https://www.w3.org/TR/webdriver/#get-current-url
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getCurrentURL(WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::back(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §9.3 Back.
|
|
|
|
// https://www.w3.org/TR/webdriver/#back
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->back(WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::forward(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §9.4 Forward.
|
|
|
|
// https://www.w3.org/TR/webdriver/#forward
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->forward(WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::refresh(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §9.5 Refresh.
|
|
|
|
// https://www.w3.org/TR/webdriver/#refresh
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->refresh(WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getTitle(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §9.6 Get Title.
|
|
|
|
// https://www.w3.org/TR/webdriver/#get-title
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getTitle(WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getWindowHandle(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §10.1 Get Window Handle.
|
|
|
|
// https://www.w3.org/TR/webdriver/#get-window-handle
|
2017-12-01 09:47:15 +00:00
|
|
|
if (findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
m_session->getWindowHandle(WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getWindowRect(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
2017-09-20 06:32:35 +00:00
|
|
|
// §10.7.1 Get Window Rect.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#get-window-rect
|
2017-12-01 09:47:15 +00:00
|
|
|
if (findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
m_session->getWindowRect(WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::setWindowRect(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
2017-09-20 06:32:35 +00:00
|
|
|
// §10.7.2 Set Window Rect.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#set-window-rect
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<double> width;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = parameters->getValue("width"_s)) {
|
2017-09-20 06:32:35 +00:00
|
|
|
if (auto number = valueAsNumberInRange(*value))
|
|
|
|
width = number;
|
|
|
|
else if (!value->isNull()) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<double> height;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = parameters->getValue("height"_s)) {
|
2017-09-20 06:32:35 +00:00
|
|
|
if (auto number = valueAsNumberInRange(*value))
|
|
|
|
height = number;
|
|
|
|
else if (!value->isNull()) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<double> x;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = parameters->getValue("x"_s)) {
|
2017-09-20 06:32:35 +00:00
|
|
|
if (auto number = valueAsNumberInRange(*value, INT_MIN))
|
|
|
|
x = number;
|
|
|
|
else if (!value->isNull()) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<double> y;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = parameters->getValue("y"_s)) {
|
2017-09-20 06:32:35 +00:00
|
|
|
if (auto number = valueAsNumberInRange(*value, INT_MIN))
|
|
|
|
y = number;
|
|
|
|
else if (!value->isNull()) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-09-20 06:32:35 +00:00
|
|
|
// FIXME: If the remote end does not support the Set Window Rect command for the current
|
|
|
|
// top-level browsing context for any reason, return error with error code unsupported operation.
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
if (findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
m_session->setWindowRect(x, y, width, height, WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2018-05-24 08:54:37 +00:00
|
|
|
void WebDriverService::maximizeWindow(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §10.7.3 Maximize Window
|
|
|
|
// https://w3c.github.io/webdriver/#maximize-window
|
|
|
|
if (findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
m_session->maximizeWindow(WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebDriverService::minimizeWindow(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §10.7.4 Minimize Window
|
|
|
|
// https://w3c.github.io/webdriver/#minimize-window
|
|
|
|
if (findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
m_session->minimizeWindow(WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebDriverService::fullscreenWindow(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §10.7.5 Fullscreen Window
|
|
|
|
// https://w3c.github.io/webdriver/#fullscreen-window
|
|
|
|
if (findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
m_session->fullscreenWindow(WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::closeWindow(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §10.2 Close Window.
|
|
|
|
// https://www.w3.org/TR/webdriver/#close-window
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-16 11:38:22 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->closeWindow([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-16 11:38:22 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto handles = result.result()->asArray();
|
|
|
|
if (handles && !handles->length())
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session = nullptr;
|
|
|
|
|
2017-08-16 11:38:22 +00:00
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::switchToWindow(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §10.3 Switch To Window.
|
|
|
|
// https://www.w3.org/TR/webdriver/#switch-to-window
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto handle = parameters->getString("handle"_s);
|
|
|
|
if (!handle) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->switchToWindow(handle, WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getWindowHandles(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §10.4 Get Window Handles.
|
|
|
|
// https://www.w3.org/TR/webdriver/#get-window-handles
|
2017-12-01 09:47:15 +00:00
|
|
|
if (findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
m_session->getWindowHandles(WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2019-11-12 08:12:40 +00:00
|
|
|
void WebDriverService::newWindow(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §11.5 New Window
|
|
|
|
// https://w3c.github.io/webdriver/#new-window
|
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
return;
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<String> typeHint;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = parameters->getValue("type"_s)) {
|
|
|
|
auto valueString = value->asString();
|
2020-09-15 06:25:04 +00:00
|
|
|
if (!!valueString) {
|
|
|
|
if (valueString == "window" || valueString == "tab")
|
|
|
|
typeHint = valueString;
|
|
|
|
} else if (!value->isNull()) {
|
2019-11-12 08:12:40 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_session->newWindow(typeHint, WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::switchToFrame(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §10.5 Switch To Frame.
|
|
|
|
// https://www.w3.org/TR/webdriver/#switch-to-frame
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto frameID = parameters->getValue("id"_s);
|
|
|
|
if (!frameID) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-13 14:38:06 +00:00
|
|
|
switch (frameID->type()) {
|
|
|
|
case JSON::Value::Type::Null:
|
|
|
|
break;
|
|
|
|
case JSON::Value::Type::Double:
|
|
|
|
case JSON::Value::Type::Integer:
|
|
|
|
if (!valueAsNumberInRange(*frameID, 0, std::numeric_limits<unsigned short>::max())) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case JSON::Value::Type::Object: {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto frameIDObject = frameID->asObject();
|
2019-11-13 14:38:06 +00:00
|
|
|
if (frameIDObject->find(Session::webElementIdentifier()) == frameIDObject->end()) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case JSON::Value::Type::Boolean:
|
|
|
|
case JSON::Value::Type::String:
|
|
|
|
case JSON::Value::Type::Array:
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, frameID, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->switchToFrame(WTFMove(frameID), WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::switchToParentFrame(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §10.6 Switch To Parent Frame.
|
|
|
|
// https://www.w3.org/TR/webdriver/#switch-to-parent-frame
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->switchToParentFrame(WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<String> findElementOrCompleteWithError(JSON::Object& parameters, Function<void (CommandResult&&)>& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto elementID = parameters.getString("elementId"_s);
|
|
|
|
if (elementID.isEmpty()) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
return elementID;
|
|
|
|
}
|
|
|
|
|
2017-11-30 13:48:46 +00:00
|
|
|
static inline bool isValidStrategy(const String& strategy)
|
|
|
|
{
|
|
|
|
// §12.1 Locator Strategies.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-table-of-location-strategies
|
|
|
|
return strategy == "css selector"
|
|
|
|
|| strategy == "link text"
|
|
|
|
|| strategy == "partial link text"
|
|
|
|
|| strategy == "tag name"
|
|
|
|
|| strategy == "xpath";
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
static bool findStrategyAndSelectorOrCompleteWithError(JSON::Object& parameters, Function<void (CommandResult&&)>& completionHandler, String& strategy, String& selector)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
strategy = parameters.getString("using"_s);
|
|
|
|
if (!isValidStrategy(strategy)) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return false;
|
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
selector = parameters.getString("value"_s);
|
|
|
|
if (!selector) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::findElement(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §12.2 Find Element.
|
|
|
|
// https://www.w3.org/TR/webdriver/#find-element
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
String strategy, selector;
|
|
|
|
if (!findStrategyAndSelectorOrCompleteWithError(*parameters, completionHandler, strategy, selector))
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, strategy = WTFMove(strategy), selector = WTFMove(selector), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->findElements(strategy, selector, Session::FindElementsMode::Single, emptyString(), WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::findElements(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §12.3 Find Elements.
|
|
|
|
// https://www.w3.org/TR/webdriver/#find-elements
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
String strategy, selector;
|
|
|
|
if (!findStrategyAndSelectorOrCompleteWithError(*parameters, completionHandler, strategy, selector))
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, strategy = WTFMove(strategy), selector = WTFMove(selector), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->findElements(strategy, selector, Session::FindElementsMode::Multiple, emptyString(), WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::findElementFromElement(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §12.4 Find Element From Element.
|
|
|
|
// https://www.w3.org/TR/webdriver/#find-element-from-element
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
|
|
|
String strategy, selector;
|
|
|
|
if (!findStrategyAndSelectorOrCompleteWithError(*parameters, completionHandler, strategy, selector))
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->findElements(strategy, selector, Session::FindElementsMode::Single, elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::findElementsFromElement(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §12.5 Find Elements From Element.
|
|
|
|
// https://www.w3.org/TR/webdriver/#find-elements-from-element
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
|
|
|
String strategy, selector;
|
|
|
|
if (!findStrategyAndSelectorOrCompleteWithError(*parameters, completionHandler, strategy, selector))
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->findElements(strategy, selector, Session::FindElementsMode::Multiple, elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getActiveElement(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-11-28 07:55:36 +00:00
|
|
|
{
|
|
|
|
// §12.6 Get Active Element.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#get-active-element
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-11-28 07:55:36 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-11-28 07:55:36 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getActiveElement(WTFMove(completionHandler));
|
2017-11-28 07:55:36 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::isElementSelected(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §13.1 Is Element Selected.
|
|
|
|
// https://www.w3.org/TR/webdriver/#is-element-selected
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->isElementSelected(elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getElementAttribute(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §13.2 Get Element Attribute.
|
|
|
|
// https://www.w3.org/TR/webdriver/#get-element-attribute
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto attribute = parameters->getString("name"_s);
|
|
|
|
if (!attribute) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getElementAttribute(elementID.value(), attribute, WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 11:29:29 +00:00
|
|
|
void WebDriverService::getElementProperty(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §13.3 Get Element Property
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#get-element-property
|
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto attribute = parameters->getString("name"_s);
|
|
|
|
if (!attribute) {
|
2017-12-04 11:29:29 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_session->getElementProperty(elementID.value(), attribute, WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
2018-01-22 14:33:32 +00:00
|
|
|
void WebDriverService::getElementCSSValue(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §13.4 Get Element CSS Value
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#get-element-css-value
|
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto cssProperty = parameters->getString("name"_s);
|
|
|
|
if (!cssProperty) {
|
2018-01-22 14:33:32 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_session->getElementCSSValue(elementID.value(), cssProperty, WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getElementText(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §13.5 Get Element Text.
|
|
|
|
// https://www.w3.org/TR/webdriver/#get-element-text
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getElementText(elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getElementTagName(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §13.6 Get Element Tag Name.
|
|
|
|
// https://www.w3.org/TR/webdriver/#get-element-tag-name
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getElementTagName(elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getElementRect(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §13.7 Get Element Rect.
|
|
|
|
// https://www.w3.org/TR/webdriver/#get-element-rect
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getElementRect(elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::isElementEnabled(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §13.8 Is Element Enabled.
|
|
|
|
// https://www.w3.org/TR/webdriver/#is-element-enabled
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->isElementEnabled(elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::isElementDisplayed(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §C. Element Displayedness.
|
|
|
|
// https://www.w3.org/TR/webdriver/#element-displayedness
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->isElementDisplayed(elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::elementClick(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §14.1 Element Click.
|
|
|
|
// https://www.w3.org/TR/webdriver/#element-click
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->elementClick(elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::elementClear(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §14.2 Element Clear.
|
|
|
|
// https://www.w3.org/TR/webdriver/#element-clear
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->elementClear(elementID.value(), WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::elementSendKeys(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §14.3 Element Send Keys.
|
|
|
|
// https://www.w3.org/TR/webdriver/#element-send-keys
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto text = parameters->getString("text"_s);
|
|
|
|
if (text.isEmpty()) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-14 06:49:25 +00:00
|
|
|
m_session->elementSendKeys(elementID.value(), text, WTFMove(completionHandler));
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2019-11-08 15:09:00 +00:00
|
|
|
void WebDriverService::getPageSource(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §15.1 Getting Page Source.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#getting-page-source
|
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_session->getPageSource(WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
static bool findScriptAndArgumentsOrCompleteWithError(JSON::Object& parameters, Function<void (CommandResult&&)>& completionHandler, String& script, RefPtr<JSON::Array>& arguments)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
script = parameters.getString("script"_s);
|
|
|
|
if (!script) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return false;
|
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
arguments = parameters.getArray("args"_s);
|
|
|
|
if (!arguments) {
|
2017-07-18 07:20:33 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::executeScript(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §15.2.1 Execute Script.
|
|
|
|
// https://www.w3.org/TR/webdriver/#execute-script
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
String script;
|
2017-11-28 19:58:16 +00:00
|
|
|
RefPtr<JSON::Array> arguments;
|
2017-07-18 07:20:33 +00:00
|
|
|
if (!findScriptAndArgumentsOrCompleteWithError(*parameters, completionHandler, script, arguments))
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, script = WTFMove(script), arguments = WTFMove(arguments), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->executeScript(script, WTFMove(arguments), Session::ExecuteScriptMode::Sync, WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::executeAsyncScript(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-07-18 07:20:33 +00:00
|
|
|
{
|
|
|
|
// §15.2.2 Execute Async Script.
|
|
|
|
// https://www.w3.org/TR/webdriver/#execute-async-script
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-07-18 07:20:33 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
String script;
|
2017-11-28 19:58:16 +00:00
|
|
|
RefPtr<JSON::Array> arguments;
|
2017-07-18 07:20:33 +00:00
|
|
|
if (!findScriptAndArgumentsOrCompleteWithError(*parameters, completionHandler, script, arguments))
|
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, script = WTFMove(script), arguments = WTFMove(arguments), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->executeScript(script, WTFMove(arguments), Session::ExecuteScriptMode::Async, WTFMove(completionHandler));
|
WebDriver: wait until navigation is complete before running new commands and after a click
https://bugs.webkit.org/show_bug.cgi?id=174670
Reviewed by Brian Burg.
Source/WebDriver:
We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
the spec says we should always wait before executing a new command and also after a click. This is causing test
testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
+ .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
most of the times.
6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
jump to step 1 in this overall algorithm, otherwise continue.
https://www.w3.org/TR/webdriver/#processing-model
14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
value if it is an error. 2. Try to wait for navigation to complete.
https://www.w3.org/TR/webdriver/#element-click
* Session.cpp:
(WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
wait for any pending navigation of current browsing context to complete.
(WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
* Session.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
(WebDriver::WebDriverService::getCurrentURL): Ditto.
(WebDriver::WebDriverService::back): Ditto.
(WebDriver::WebDriverService::forward): Ditto.
(WebDriver::WebDriverService::refresh): Ditto.
(WebDriver::WebDriverService::getTitle): Ditto.
(WebDriver::WebDriverService::switchToFrame): Ditto.
(WebDriver::WebDriverService::switchToParentFrame): Ditto.
(WebDriver::WebDriverService::findElement): Ditto.
(WebDriver::WebDriverService::findElements): Ditto.
(WebDriver::WebDriverService::executeScript): Ditto.
(WebDriver::WebDriverService::executeAsyncScript): Ditto.
Source/WebKit:
Add waitForNavigationToComplete method to Automation to allow WebDriver to wait for pending navigations to
complete. The new method already receives page load strategy and timeout, but they are not implemented yet.
* UIProcess/Automation/Automation.json: Add waitForNavigationToComplete method and PageLoadStrategy new type.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::waitForNavigationToComplete): Call waitForNavigationToCompleteOnPage or
waitForNavigationToCompleteOnFrame depending on whether the current borwsing context is the main frame or not.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnPage): Check if there's an ongoing load for the page,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::waitForNavigationToCompleteOnFrame): Check if there's an ongoing load for the frame,
and wait for it to complete if needed.
(WebKit::WebAutomationSession::navigateBrowsingContext): Use waitForNavigationToCompleteOnPage() now.
(WebKit::WebAutomationSession::goBackInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::goForwardInBrowsingContext): Ditto.
(WebKit::WebAutomationSession::reloadBrowsingContext): Ditto.
(WebKit::WebAutomationSession::navigationOccurredForFrame): Renamed since it now receives the notification for
all the frames. Complete page operations if it's a main frame, or frame operations otherwise.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didFinishLoadForFrame): Notify about all frames, not only the main one.
(WebKit::WebPageProxy::didFailLoadForFrame): Ditto.
(WebKit::WebPageProxy::didSameDocumentNavigationForFrame): Ditto.
Canonical link: https://commits.webkit.org/191531@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-07-21 09:50:49 +00:00
|
|
|
});
|
2017-07-18 07:20:33 +00:00
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getAllCookies(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-28 11:52:55 +00:00
|
|
|
{
|
|
|
|
// §16.1 Get All Cookies.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#get-all-cookies
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-28 11:52:55 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-28 11:52:55 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getAllCookies(WTFMove(completionHandler));
|
2017-08-28 11:52:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getNamedCookie(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-28 11:52:55 +00:00
|
|
|
{
|
|
|
|
// §16.2 Get Named Cookie.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#get-named-cookie
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-28 11:52:55 +00:00
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto name = parameters->getString("name"_s);
|
|
|
|
if (!name) {
|
2017-08-28 11:52:55 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, name = WTFMove(name), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-28 11:52:55 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getNamedCookie(name, WTFMove(completionHandler));
|
2017-08-28 11:52:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<Session::Cookie> deserializeCookie(JSON::Object& cookieObject)
|
2017-08-28 11:52:55 +00:00
|
|
|
{
|
|
|
|
Session::Cookie cookie;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
cookie.name = cookieObject.getString("name"_s);
|
|
|
|
if (cookie.name.isEmpty())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
cookie.value = cookieObject.getString("value"_s);
|
|
|
|
if (cookie.value.isEmpty())
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-08-28 11:52:55 +00:00
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = cookieObject.getValue("path"_s)) {
|
|
|
|
auto path = value->asString();
|
|
|
|
if (!path)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-08-28 11:52:55 +00:00
|
|
|
cookie.path = path;
|
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = cookieObject.getValue("domain"_s)) {
|
|
|
|
auto domain = value->asString();
|
|
|
|
if (!domain)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-08-28 11:52:55 +00:00
|
|
|
cookie.domain = domain;
|
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = cookieObject.getValue("secure"_s)) {
|
|
|
|
auto secure = value->asBoolean();
|
|
|
|
if (!secure)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-08-28 11:52:55 +00:00
|
|
|
cookie.secure = secure;
|
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = cookieObject.getValue("httpOnly"_s)) {
|
|
|
|
auto httpOnly = value->asBoolean();
|
|
|
|
if (!httpOnly)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2017-08-28 11:52:55 +00:00
|
|
|
cookie.httpOnly = httpOnly;
|
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (auto value = cookieObject.getValue("expiry"_s)) {
|
2018-01-26 09:50:58 +00:00
|
|
|
auto expiry = unsignedValue(*value);
|
|
|
|
if (!expiry)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-01-26 09:50:58 +00:00
|
|
|
cookie.expiry = expiry.value();
|
2017-08-28 11:52:55 +00:00
|
|
|
}
|
2020-10-03 06:28:13 +00:00
|
|
|
if (auto value = cookieObject.getValue("sameSite"_s)) {
|
|
|
|
auto sameSite = value->asString();
|
|
|
|
if (sameSite != "None"_s && sameSite != "Lax"_s && sameSite != "Strict"_s)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2020-10-03 06:28:13 +00:00
|
|
|
cookie.sameSite = sameSite;
|
|
|
|
}
|
2017-08-28 11:52:55 +00:00
|
|
|
|
|
|
|
return cookie;
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::addCookie(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-28 11:52:55 +00:00
|
|
|
{
|
|
|
|
// §16.3 Add Cookie.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#add-cookie
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-28 11:52:55 +00:00
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto cookieObject = parameters->getObject("cookie"_s);
|
|
|
|
if (!cookieObject) {
|
2017-08-28 11:52:55 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto cookie = deserializeCookie(*cookieObject);
|
|
|
|
if (!cookie) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, cookie = WTFMove(cookie), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-28 11:52:55 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->addCookie(cookie.value(), WTFMove(completionHandler));
|
2017-08-28 11:52:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::deleteCookie(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-28 11:52:55 +00:00
|
|
|
{
|
|
|
|
// §16.4 Delete Cookie.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#delete-cookie
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-28 11:52:55 +00:00
|
|
|
return;
|
|
|
|
|
2020-09-15 06:25:04 +00:00
|
|
|
auto name = parameters->getString("name"_s);
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
if (!name) {
|
2017-08-28 11:52:55 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, name = WTFMove(name), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-28 11:52:55 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->deleteCookie(name, WTFMove(completionHandler));
|
2017-08-28 11:52:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::deleteAllCookies(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-28 11:52:55 +00:00
|
|
|
{
|
|
|
|
// §16.5 Delete All Cookies.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#delete-all-cookies
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-28 11:52:55 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-28 11:52:55 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->deleteAllCookies(WTFMove(completionHandler));
|
2017-08-28 11:52:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static bool processPauseAction(JSON::Object& actionItem, Action& action, std::optional<String>& errorMessage)
|
2018-05-10 06:52:31 +00:00
|
|
|
{
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto durationValue = actionItem.getValue("duration"_s);
|
|
|
|
if (!durationValue)
|
2019-11-13 14:40:22 +00:00
|
|
|
return true;
|
2018-05-10 06:52:31 +00:00
|
|
|
|
|
|
|
auto duration = unsignedValue(*durationValue);
|
|
|
|
if (!duration) {
|
|
|
|
errorMessage = String("The parameter 'duration' is invalid in pause action");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
action.duration = duration.value();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<Action> processNullAction(const String& id, JSON::Object& actionItem, std::optional<String>& errorMessage)
|
2018-05-10 06:52:31 +00:00
|
|
|
{
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto subtype = actionItem.getString("type"_s);
|
2018-05-10 06:52:31 +00:00
|
|
|
if (subtype != "pause") {
|
|
|
|
errorMessage = String("The parameter 'type' in null action is invalid or missing");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Action action(id, Action::Type::None, Action::Subtype::Pause);
|
|
|
|
if (!processPauseAction(actionItem, action, errorMessage))
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<Action> processKeyAction(const String& id, JSON::Object& actionItem, std::optional<String>& errorMessage)
|
2018-05-10 06:52:31 +00:00
|
|
|
{
|
|
|
|
Action::Subtype actionSubtype;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto subtype = actionItem.getString("type"_s);
|
2018-05-10 06:52:31 +00:00
|
|
|
if (subtype == "pause")
|
|
|
|
actionSubtype = Action::Subtype::Pause;
|
|
|
|
else if (subtype == "keyUp")
|
|
|
|
actionSubtype = Action::Subtype::KeyUp;
|
|
|
|
else if (subtype == "keyDown")
|
|
|
|
actionSubtype = Action::Subtype::KeyDown;
|
|
|
|
else {
|
|
|
|
errorMessage = String("The parameter 'type' of key action is invalid");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Action action(id, Action::Type::Key, actionSubtype);
|
|
|
|
|
|
|
|
switch (actionSubtype) {
|
|
|
|
case Action::Subtype::Pause:
|
|
|
|
if (!processPauseAction(actionItem, action, errorMessage))
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
break;
|
|
|
|
case Action::Subtype::KeyUp:
|
|
|
|
case Action::Subtype::KeyDown: {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto keyValue = actionItem.getValue("value"_s);
|
|
|
|
if (!keyValue) {
|
2018-05-10 06:52:31 +00:00
|
|
|
errorMessage = String("The paramater 'value' is missing for key up/down action");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto key = keyValue->asString();
|
2020-09-15 06:25:04 +00:00
|
|
|
if (key.isEmpty()) {
|
2018-05-10 06:52:31 +00:00
|
|
|
errorMessage = String("The paramater 'value' is invalid for key up/down action");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
// FIXME: check single unicode code point.
|
|
|
|
action.key = key;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Action::Subtype::PointerUp:
|
|
|
|
case Action::Subtype::PointerDown:
|
|
|
|
case Action::Subtype::PointerMove:
|
|
|
|
case Action::Subtype::PointerCancel:
|
2020-10-21 12:36:18 +00:00
|
|
|
case Action::Subtype::Scroll:
|
2018-05-10 06:52:31 +00:00
|
|
|
ASSERT_NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MouseButton actionMouseButton(unsigned button)
|
|
|
|
{
|
|
|
|
// MouseEvent.button
|
|
|
|
// https://www.w3.org/TR/uievents/#ref-for-dom-mouseevent-button-1
|
|
|
|
switch (button) {
|
|
|
|
case 0:
|
|
|
|
return MouseButton::Left;
|
|
|
|
case 1:
|
|
|
|
return MouseButton::Middle;
|
|
|
|
case 2:
|
|
|
|
return MouseButton::Right;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MouseButton::None;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static bool processPointerMoveAction(JSON::Object& actionItem, Action& action, std::optional<String>& errorMessage)
|
2020-10-21 12:36:18 +00:00
|
|
|
{
|
|
|
|
if (auto durationValue = actionItem.getValue("duration"_s)) {
|
|
|
|
auto duration = unsignedValue(*durationValue);
|
|
|
|
if (!duration) {
|
|
|
|
errorMessage = String("The parameter 'duration' is invalid in action");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
action.duration = duration.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto originValue = actionItem.getValue("origin"_s)) {
|
|
|
|
if (auto originObject = originValue->asObject()) {
|
|
|
|
auto elementID = originObject->getString(Session::webElementIdentifier());
|
|
|
|
if (!elementID) {
|
|
|
|
errorMessage = String("The parameter 'origin' is not a valid web element object in action");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
action.origin = PointerOrigin { PointerOrigin::Type::Element, elementID };
|
|
|
|
} else {
|
|
|
|
auto origin = originValue->asString();
|
|
|
|
if (origin == "viewport")
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
action.origin = PointerOrigin { PointerOrigin::Type::Viewport, std::nullopt };
|
2020-10-21 12:36:18 +00:00
|
|
|
else if (origin == "pointer")
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
action.origin = PointerOrigin { PointerOrigin::Type::Pointer, std::nullopt };
|
2020-10-21 12:36:18 +00:00
|
|
|
else {
|
|
|
|
errorMessage = String("The parameter 'origin' is invalid in action");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
action.origin = PointerOrigin { PointerOrigin::Type::Viewport, std::nullopt };
|
2020-10-21 12:36:18 +00:00
|
|
|
|
|
|
|
if (auto xValue = actionItem.getValue("x"_s)) {
|
|
|
|
auto x = valueAsNumberInRange(*xValue, INT_MIN);
|
|
|
|
if (!x) {
|
|
|
|
errorMessage = String("The paramater 'x' is invalid for action");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
action.x = x.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto yValue = actionItem.getValue("y"_s)) {
|
|
|
|
auto y = valueAsNumberInRange(*yValue, INT_MIN);
|
|
|
|
if (!y) {
|
|
|
|
errorMessage = String("The paramater 'y' is invalid for action");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
action.y = y.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<Action> processPointerAction(const String& id, PointerParameters& parameters, JSON::Object& actionItem, std::optional<String>& errorMessage)
|
2018-05-10 06:52:31 +00:00
|
|
|
{
|
|
|
|
Action::Subtype actionSubtype;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto subtype = actionItem.getString("type"_s);
|
2018-05-10 06:52:31 +00:00
|
|
|
if (subtype == "pause")
|
|
|
|
actionSubtype = Action::Subtype::Pause;
|
|
|
|
else if (subtype == "pointerUp")
|
|
|
|
actionSubtype = Action::Subtype::PointerUp;
|
|
|
|
else if (subtype == "pointerDown")
|
|
|
|
actionSubtype = Action::Subtype::PointerDown;
|
|
|
|
else if (subtype == "pointerMove")
|
|
|
|
actionSubtype = Action::Subtype::PointerMove;
|
|
|
|
else if (subtype == "pointerCancel")
|
|
|
|
actionSubtype = Action::Subtype::PointerCancel;
|
|
|
|
else {
|
|
|
|
errorMessage = String("The parameter 'type' of pointer action is invalid");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Action action(id, Action::Type::Pointer, actionSubtype);
|
|
|
|
action.pointerType = parameters.pointerType;
|
|
|
|
|
|
|
|
switch (actionSubtype) {
|
|
|
|
case Action::Subtype::Pause:
|
|
|
|
if (!processPauseAction(actionItem, action, errorMessage))
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
break;
|
|
|
|
case Action::Subtype::PointerUp:
|
|
|
|
case Action::Subtype::PointerDown: {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto buttonValue = actionItem.getValue("button"_s);
|
|
|
|
if (!buttonValue) {
|
2018-05-10 06:52:31 +00:00
|
|
|
errorMessage = String("The paramater 'button' is missing for pointer up/down action");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
auto button = unsignedValue(*buttonValue);
|
|
|
|
if (!button) {
|
|
|
|
errorMessage = String("The paramater 'button' is invalid for pointer up/down action");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
action.button = actionMouseButton(button.value());
|
|
|
|
break;
|
|
|
|
}
|
2020-10-21 12:36:18 +00:00
|
|
|
case Action::Subtype::PointerMove:
|
|
|
|
if (!processPointerMoveAction(actionItem, action, errorMessage))
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2020-10-21 12:36:18 +00:00
|
|
|
break;
|
|
|
|
case Action::Subtype::PointerCancel:
|
|
|
|
break;
|
|
|
|
case Action::Subtype::KeyUp:
|
|
|
|
case Action::Subtype::KeyDown:
|
|
|
|
case Action::Subtype::Scroll:
|
|
|
|
ASSERT_NOT_REACHED();
|
|
|
|
}
|
2018-05-10 06:52:31 +00:00
|
|
|
|
2020-10-21 12:36:18 +00:00
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<Action> processWheelAction(const String& id, JSON::Object& actionItem, std::optional<String>& errorMessage)
|
2020-10-21 12:36:18 +00:00
|
|
|
{
|
|
|
|
Action::Subtype actionSubtype;
|
|
|
|
auto subtype = actionItem.getString("type"_s);
|
|
|
|
if (subtype == "pause")
|
|
|
|
actionSubtype = Action::Subtype::Pause;
|
|
|
|
else if (subtype == "scroll")
|
|
|
|
actionSubtype = Action::Subtype::Scroll;
|
|
|
|
else {
|
|
|
|
errorMessage = String("The parameter 'type' of wheel action is invalid");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2020-10-21 12:36:18 +00:00
|
|
|
}
|
2018-05-10 06:52:31 +00:00
|
|
|
|
2020-10-21 12:36:18 +00:00
|
|
|
Action action(id, Action::Type::Wheel, actionSubtype);
|
|
|
|
|
|
|
|
switch (actionSubtype) {
|
|
|
|
case Action::Subtype::Pause:
|
|
|
|
if (!processPauseAction(actionItem, action, errorMessage))
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2020-10-21 12:36:18 +00:00
|
|
|
break;
|
|
|
|
case Action::Subtype::Scroll:
|
|
|
|
if (!processPointerMoveAction(actionItem, action, errorMessage))
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2020-10-21 12:36:18 +00:00
|
|
|
|
|
|
|
if (auto deltaXValue = actionItem.getValue("deltaX"_s)) {
|
|
|
|
auto deltaX = valueAsNumberInRange(*deltaXValue, INT_MIN);
|
|
|
|
if (!deltaX) {
|
|
|
|
errorMessage = String("The paramater 'deltaX' is invalid for action");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
2020-10-21 12:36:18 +00:00
|
|
|
action.deltaX = deltaX.value();
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
2020-10-21 12:36:18 +00:00
|
|
|
if (auto deltaYValue = actionItem.getValue("deltaY"_s)) {
|
|
|
|
auto deltaY = valueAsNumberInRange(*deltaYValue, INT_MIN);
|
|
|
|
if (!deltaY) {
|
|
|
|
errorMessage = String("The paramater 'deltaY' is invalid for action");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
2020-10-21 12:36:18 +00:00
|
|
|
action.deltaY = deltaY.value();
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Action::Subtype::KeyUp:
|
|
|
|
case Action::Subtype::KeyDown:
|
2020-10-21 12:36:18 +00:00
|
|
|
case Action::Subtype::PointerUp:
|
|
|
|
case Action::Subtype::PointerDown:
|
|
|
|
case Action::Subtype::PointerMove:
|
|
|
|
case Action::Subtype::PointerCancel:
|
2018-05-10 06:52:31 +00:00
|
|
|
ASSERT_NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<PointerParameters> processPointerParameters(JSON::Object& actionSequence, std::optional<String>& errorMessage)
|
2018-05-10 06:52:31 +00:00
|
|
|
{
|
|
|
|
PointerParameters parameters;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
|
|
|
|
auto parametersDataValue = actionSequence.getValue("parameters"_s);
|
|
|
|
if (!parametersDataValue)
|
2018-05-10 06:52:31 +00:00
|
|
|
return parameters;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto parametersData = parametersDataValue->asObject();
|
|
|
|
if (!parametersData) {
|
2018-05-10 06:52:31 +00:00
|
|
|
errorMessage = String("Action sequence pointer parameters is not an object");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto pointerType = parametersData->getString("pointerType"_s);
|
|
|
|
if (!pointerType)
|
2018-05-10 06:52:31 +00:00
|
|
|
return parameters;
|
|
|
|
|
|
|
|
if (pointerType == "mouse")
|
|
|
|
parameters.pointerType = PointerType::Mouse;
|
|
|
|
else if (pointerType == "pen")
|
|
|
|
parameters.pointerType = PointerType::Pen;
|
|
|
|
else if (pointerType == "touch")
|
|
|
|
parameters.pointerType = PointerType::Touch;
|
|
|
|
else {
|
|
|
|
errorMessage = String("The parameter 'pointerType' in action sequence pointer parameters is invalid");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return parameters;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<Vector<Action>> processInputActionSequence(Session& session, JSON::Value& actionSequenceValue, std::optional<String>& errorMessage)
|
2018-05-10 06:52:31 +00:00
|
|
|
{
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto actionSequence = actionSequenceValue.asObject();
|
|
|
|
if (!actionSequence) {
|
2018-05-10 06:52:31 +00:00
|
|
|
errorMessage = String("The action sequence is not an object");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto type = actionSequence->getString("type"_s);
|
2018-05-10 06:52:31 +00:00
|
|
|
InputSource::Type inputSourceType;
|
|
|
|
if (type == "key")
|
|
|
|
inputSourceType = InputSource::Type::Key;
|
|
|
|
else if (type == "pointer")
|
|
|
|
inputSourceType = InputSource::Type::Pointer;
|
2020-10-21 12:36:18 +00:00
|
|
|
else if (type == "wheel")
|
|
|
|
inputSourceType = InputSource::Type::Wheel;
|
2018-05-10 06:52:31 +00:00
|
|
|
else if (type == "none")
|
|
|
|
inputSourceType = InputSource::Type::None;
|
|
|
|
else {
|
|
|
|
errorMessage = String("The parameter 'type' is invalid or missing in action sequence");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto id = actionSequence->getString("id"_s);
|
|
|
|
if (!id) {
|
2018-05-10 06:52:31 +00:00
|
|
|
errorMessage = String("The parameter 'id' is invalid or missing in action sequence");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<PointerParameters> parameters;
|
|
|
|
std::optional<PointerType> pointerType;
|
2018-05-10 06:52:31 +00:00
|
|
|
if (inputSourceType == InputSource::Type::Pointer) {
|
|
|
|
parameters = processPointerParameters(*actionSequence, errorMessage);
|
|
|
|
if (!parameters)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
|
|
|
|
pointerType = parameters->pointerType;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto& inputSource = session.getOrCreateInputSource(id, inputSourceType, pointerType);
|
|
|
|
if (inputSource.type != inputSourceType) {
|
|
|
|
errorMessage = String("Action sequence type doesn't match input source type");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (inputSource.type == InputSource::Type::Pointer && inputSource.pointerType != pointerType) {
|
|
|
|
errorMessage = String("Action sequence pointer type doesn't match input source pointer type");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto actionItems = actionSequence->getArray("actions"_s);
|
|
|
|
if (!actionItems) {
|
2018-05-10 06:52:31 +00:00
|
|
|
errorMessage = String("The parameter 'actions' is invalid or not present in action sequence");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Vector<Action> actions;
|
|
|
|
unsigned actionItemsLength = actionItems->length();
|
|
|
|
for (unsigned i = 0; i < actionItemsLength; ++i) {
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto actionItem = actionItems->get(i)->asObject();
|
|
|
|
if (!actionItem) {
|
2018-05-10 06:52:31 +00:00
|
|
|
errorMessage = String("An action in action sequence is not an object");
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<Action> action;
|
2018-05-10 06:52:31 +00:00
|
|
|
if (inputSourceType == InputSource::Type::None)
|
|
|
|
action = processNullAction(id, *actionItem, errorMessage);
|
|
|
|
else if (inputSourceType == InputSource::Type::Key)
|
|
|
|
action = processKeyAction(id, *actionItem, errorMessage);
|
|
|
|
else if (inputSourceType == InputSource::Type::Pointer)
|
|
|
|
action = processPointerAction(id, parameters.value(), *actionItem, errorMessage);
|
2020-10-21 12:36:18 +00:00
|
|
|
else if (inputSourceType == InputSource::Type::Wheel)
|
|
|
|
action = processWheelAction(id, *actionItem, errorMessage);
|
2018-05-10 06:52:31 +00:00
|
|
|
if (!action)
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
return std::nullopt;
|
2018-05-10 06:52:31 +00:00
|
|
|
|
|
|
|
actions.append(action.value());
|
|
|
|
}
|
|
|
|
|
|
|
|
return actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebDriverService::performActions(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §17.5 Perform Actions.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#perform-actions
|
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto actionsArray = parameters->getArray("actions"_s);
|
|
|
|
if (!actionsArray) {
|
2018-05-10 06:52:31 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument, String("The paramater 'actions' is invalid or not present")));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
std::optional<String> errorMessage;
|
2018-05-10 06:52:31 +00:00
|
|
|
Vector<Vector<Action>> actionsByTick;
|
|
|
|
unsigned actionsArrayLength = actionsArray->length();
|
|
|
|
for (unsigned i = 0; i < actionsArrayLength; ++i) {
|
|
|
|
auto actionSequence = actionsArray->get(i);
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto inputSourceActions = processInputActionSequence(*m_session, actionSequence, errorMessage);
|
2018-05-10 06:52:31 +00:00
|
|
|
if (!inputSourceActions) {
|
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument, errorMessage.value()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (unsigned i = 0; i < inputSourceActions->size(); ++i) {
|
|
|
|
if (actionsByTick.size() < i + 1)
|
|
|
|
actionsByTick.append({ });
|
|
|
|
actionsByTick[i].append(inputSourceActions.value()[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_session->performActions(WTFMove(actionsByTick), WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebDriverService::releaseActions(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
|
|
|
{
|
|
|
|
// §17.5 Release Actions.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#release-actions
|
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_session->releaseActions(WTFMove(completionHandler));
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::dismissAlert(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-08 06:22:02 +00:00
|
|
|
{
|
|
|
|
// §18.1 Dismiss Alert.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#dismiss-alert
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-08 06:22:02 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-08 06:22:02 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->dismissAlert(WTFMove(completionHandler));
|
2017-08-08 06:22:02 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::acceptAlert(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-08 06:22:02 +00:00
|
|
|
{
|
|
|
|
// §18.2 Accept Alert.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#accept-alert
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-08 06:22:02 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-08 06:22:02 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->acceptAlert(WTFMove(completionHandler));
|
2017-08-08 06:22:02 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::getAlertText(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-08 06:22:02 +00:00
|
|
|
{
|
|
|
|
// §18.3 Get Alert Text.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#get-alert-text
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-08 06:22:02 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-08 06:22:02 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->getAlertText(WTFMove(completionHandler));
|
2017-08-08 06:22:02 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::sendAlertText(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-08 06:22:02 +00:00
|
|
|
{
|
|
|
|
// §18.4 Send Alert Text.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#send-alert-text
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-08 06:22:02 +00:00
|
|
|
return;
|
|
|
|
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
auto text = parameters->getString("text"_s);
|
|
|
|
if (!text) {
|
2017-08-08 06:22:02 +00:00
|
|
|
completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, text = WTFMove(text), completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-08 06:22:02 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->sendAlertText(text, WTFMove(completionHandler));
|
2017-08-08 06:22:02 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::takeScreenshot(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-28 13:55:10 +00:00
|
|
|
{
|
|
|
|
// §19.1 Take Screenshot.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#take-screenshot
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-28 13:55:10 +00:00
|
|
|
return;
|
|
|
|
|
2017-12-01 09:47:15 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-28 13:55:10 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
Next step toward using std::optional directly instead of through WTF::Optional typedef
https://bugs.webkit.org/show_bug.cgi?id=226280
Reviewed by Chris Dumez.
Source/JavaScriptCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file,
tweaked style to make it happy after the renaming done by do-webcore-rename, and
also hand-updated Optional to std::optional as long as we were touching it.
Source/WebCore:
* <many files>: Accept the renaming done by do-webcore-rename.
* Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained
about the names of some arguments, fixed them, and also hand-updated Optional to
std::optional as long as we were touching it.
* loader/EmptyClients.cpp: Since style checker complained about the mix of
WEBCORE_EXPORT and inlined functions, moved them out of line, and
also hand-updated Optional to std::optional as long as we were touching it.
Also removed is<EmptyFrameLoaderClient>().
* loader/EmptyFrameLoaderClient.h: Ditto.
Source/WebCore/PAL:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebDriver:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKit:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy:
* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/mac:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WebKitLegacy/win:
* <many files>: Accept the renaming done by do-webcore-rename.
Source/WTF:
* <many files>: Accept the renaming done by do-webcore-rename.
* wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional.
* wtf/URLHelpers.cpp:
(WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt.
Tools:
* Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t,
WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily
be done by the script and so will be done in later passes.
* <many files>: Accept the renaming done by do-webcore-rename.
Canonical link: https://commits.webkit.org/238228@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
|
|
|
m_session->takeScreenshot(std::nullopt, std::nullopt, WTFMove(completionHandler));
|
2017-08-28 13:55:10 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void WebDriverService::takeElementScreenshot(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler)
|
2017-08-28 13:55:10 +00:00
|
|
|
{
|
|
|
|
// §19.2 Take Element Screenshot.
|
|
|
|
// https://w3c.github.io/webdriver/webdriver-spec.html#take-element-screenshot
|
2017-12-01 09:47:15 +00:00
|
|
|
if (!findSessionOrCompleteWithError(*parameters, completionHandler))
|
2017-08-28 13:55:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
auto elementID = findElementOrCompleteWithError(*parameters, completionHandler);
|
|
|
|
if (!elementID)
|
|
|
|
return;
|
|
|
|
|
2020-01-29 09:52:17 +00:00
|
|
|
m_session->waitForNavigationToComplete([this, elementID, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable {
|
2017-08-28 13:55:10 +00:00
|
|
|
if (result.isError()) {
|
|
|
|
completionHandler(WTFMove(result));
|
|
|
|
return;
|
|
|
|
}
|
2020-01-29 09:52:17 +00:00
|
|
|
m_session->takeScreenshot(elementID.value(), true, WTFMove(completionHandler));
|
2017-08-28 13:55:10 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-07-18 07:20:33 +00:00
|
|
|
} // namespace WebDriver
|