Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 7b9e709

Browse files
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: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent baadfeb commit 7b9e709

File tree

193 files changed

+7908
-6918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+7908
-6918
lines changed

LayoutTests/ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2020-09-10 Devin Rousso <[email protected]>
2+
3+
Web Inspector: modernize generated backend protocol code
4+
https://bugs.webkit.org/show_bug.cgi?id=216302
5+
<rdar://problem/68547649>
6+
7+
Reviewed by Brian Burg.
8+
9+
* inspector/canvas/requestShaderSource-expected.txt:
10+
* inspector/canvas/updateShader-expected.txt:
11+
* inspector/console/webcore-logging-expected.txt:
12+
* inspector/dom/highlightQuad-expected.txt:
13+
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
14+
115
2020-09-10 Sihui Liu <[email protected]>
216

317
REGRESSION (r266634): [macOS release] 4 layout tests became flaky failures

LayoutTests/inspector/canvas/requestShaderSource-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Common tests for Canvas.requestShaderSource command.
44
== Running test suite: Canvas.requestShaderSource
55
-- Running test case: Canvas.requestShaderSource.ProgramId.Invalid
66
PASS: Should produce an error.
7-
Error: Missing program for given programId
7+
Error: Unknown shaderType: INVALID_SHADER_TYPE
88

LayoutTests/inspector/canvas/updateShader-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ Common tests for Canvas.updateShader command.
44
== Running test suite: Canvas.updateShader
55
-- Running test case: Canvas.updateShader.ProgramId.Invalid
66
PASS: Should produce an error.
7-
Error: Missing program for given programId
7+
Error: Unknown shaderType: INVALID_SHADER_TYPE
88

LayoutTests/inspector/console/webcore-logging-expected.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ PASS: Log channel has known source.
1515
PASS: Log channel disabled by default.
1616
PASS: Log channel has known source.
1717
PASS: Log channel disabled by default.
18+
PASS: Log channel has known source.
19+
PASS: Log channel disabled by default.
20+
PASS: Log channel has known source.
21+
PASS: Log channel disabled by default.
1822

1923
-- Running test case: Console.Logging.InvalidLevel
20-
PASS: Unknown channelLevel: DOES_NOT_EXIST
24+
PASS: Unknown level: DOES_NOT_EXIST
2125

2226
-- Running test case: Console.Logging.NoLogging
2327
PASS: Media logging disabled.

LayoutTests/inspector/dom/highlightQuad-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Highlight Rect: {"x":-10,"y":-10,"width":1000,"height":2000,"top":-10,"right":99
3131

3232
-- Running test case: BadQuadShouldError
3333
PASS: Should produce an error.
34-
Error: Unexpected invalid quadArray
34+
Error: Unexpected invalid quad
3535

LayoutTests/inspector/worker/dom-debugger-dom-breakpoints-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Tests for DOM breakpoint functionality (DOMDebugger) in a Worker.
44
== Running test suite: Worker.DOMDebugger.DOMBreakpoint
55
-- Running test case: Worker.DOMDebugger.DOMBreakpoint.setDOMBreakpoint
66
PASS: Should produce an exception.
7-
Error: Not supported
7+
Error: Unknown type: INVALID
88

99
-- Running test case: Worker.DOMDebugger.DOMBreakpoint.removeDOMBreakpoint
1010
PASS: Should produce an exception.
11-
Error: Not supported
11+
Error: Unknown type: INVALID
1212

Source/JavaScriptCore/ChangeLog

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,230 @@
1+
2020-09-10 Devin Rousso <[email protected]>
2+
3+
Web Inspector: modernize generated backend protocol code
4+
https://bugs.webkit.org/show_bug.cgi?id=216302
5+
<rdar://problem/68547649>
6+
7+
Reviewed by Brian Burg.
8+
9+
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
10+
- the error string was the first argument
11+
- required parameters were `T` or `const T&`
12+
- optional parameters were `const T*`
13+
- enum parameters were the underlying type requiring the backend dispatcher handler to
14+
process it instead of it being preprocessed
15+
- required returns were `T&`
16+
- optional returns were `T*`
17+
This doesn't really make for easy/obvious reading of code since the order of arguments is
18+
not weird (e.g. error string first), and that there are references/pointers to primitive
19+
types.
20+
21+
This patch cleans up the generated inspector protocol code to be:
22+
- required parameters are `T` or `Ref<T>&&`
23+
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
24+
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
25+
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
26+
where `X` is either a single return or a `std::tuple` of multiple returns
27+
28+
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
29+
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
30+
31+
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
32+
JSON and the actual backend dispatcher handler implementation.
33+
34+
* inspector/scripts/codegen/generator.py:
35+
(Generator.generate_includes_from_entries):
36+
* inspector/scripts/codegen/cpp_generator_templates.py:
37+
* inspector/scripts/codegen/cpp_generator.py:
38+
(CppGenerator.helpers_namespace):
39+
(CppGenerator.cpp_getter_method_for_type):
40+
(CppGenerator.cpp_setter_method_for_type):
41+
(CppGenerator.cpp_protocol_type_for_type):
42+
(CppGenerator.cpp_type_for_type_member_argument): Added.
43+
(CppGenerator.cpp_type_for_command_parameter): Added.
44+
(CppGenerator.cpp_type_for_command_return_declaration): Added.
45+
(CppGenerator.cpp_type_for_command_return_argument): Added.
46+
(CppGenerator.cpp_type_for_event_parameter): Added.
47+
(CppGenerator.cpp_type_for_enum): Added.
48+
(CppGenerator.should_move_argument): Added.
49+
(CppGenerator.should_release_argument): Added.
50+
(CppGenerator.should_dereference_argument): Added.
51+
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
52+
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
53+
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
54+
(CppGenerator.cpp_type_for_type_member): Deleted.
55+
(CppGenerator.cpp_type_for_type_with_name): Deleted.
56+
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
57+
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
58+
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
59+
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
60+
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
61+
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
62+
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
63+
(CppGenerator.should_use_references_for_type): Deleted.
64+
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
65+
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
66+
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
67+
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
68+
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
69+
(CppBackendDispatcherHeaderGenerator.generate_output):
70+
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
71+
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
72+
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
73+
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
74+
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
75+
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
76+
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
77+
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
78+
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
79+
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
80+
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
81+
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
82+
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
83+
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
84+
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
85+
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
86+
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
87+
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
88+
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
89+
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
90+
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
91+
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
92+
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
93+
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
94+
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
95+
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
96+
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
97+
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
98+
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
99+
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
100+
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
101+
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
102+
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
103+
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
104+
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
105+
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
106+
* inspector/scripts/codegen/objc_generator_templates.py:
107+
* inspector/scripts/codegen/objc_generator.py:
108+
(ObjCGenerator.protocol_type_for_type):
109+
(ObjCGenerator.objc_type_for_param_internal):
110+
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
111+
112+
* inspector/protocol/Page.json:
113+
Now that enums are processed before being passed to backend dispacher handlers, the
114+
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
115+
there's no way for it to accept an empty string, as that's not possible for an enum.
116+
117+
* inspector/agents/InspectorAgent.h:
118+
* inspector/agents/InspectorAgent.cpp:
119+
* inspector/agents/InspectorAuditAgent.h:
120+
* inspector/agents/InspectorAuditAgent.cpp:
121+
* inspector/agents/InspectorConsoleAgent.h:
122+
* inspector/agents/InspectorConsoleAgent.cpp:
123+
* inspector/agents/InspectorDebuggerAgent.h:
124+
* inspector/agents/InspectorDebuggerAgent.cpp:
125+
* inspector/agents/InspectorHeapAgent.h:
126+
* inspector/agents/InspectorHeapAgent.cpp:
127+
* inspector/agents/InspectorRuntimeAgent.h:
128+
* inspector/agents/InspectorRuntimeAgent.cpp:
129+
* inspector/agents/InspectorScriptProfilerAgent.h:
130+
* inspector/agents/InspectorScriptProfilerAgent.cpp:
131+
* inspector/agents/InspectorTargetAgent.h:
132+
* inspector/agents/InspectorTargetAgent.cpp:
133+
* inspector/agents/JSGlobalObjectAuditAgent.h:
134+
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
135+
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
136+
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
137+
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
138+
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
139+
* inspector/JSGlobalObjectConsoleClient.cpp:
140+
* inspector/JSGlobalObjectInspectorController.cpp:
141+
Elided backend dispatcher handler changes describe above.
142+
143+
* bindings/ScriptValue.cpp:
144+
(Inspector::jsToInspectorValue):
145+
* inspector/AsyncStackTrace.h:
146+
* inspector/AsyncStackTrace.cpp:
147+
(Inspector::AsyncStackTrace::buildInspectorObject const):
148+
* inspector/ConsoleMessage.cpp:
149+
(Inspector::ConsoleMessage::addToFrontend):
150+
* inspector/InjectedScriptBase.h:
151+
* inspector/InjectedScriptBase.cpp:
152+
(Inspector::InjectedScriptBase::makeEvalCall):
153+
(Inspector::InjectedScriptBase::checkCallResult):
154+
(Inspector::InjectedScriptBase::checkAsyncCallResult):
155+
* inspector/InjectedScript.h:
156+
* inspector/InjectedScript.cpp:
157+
(Inspector::InjectedScript::execute):
158+
(Inspector::InjectedScript::evaluate):
159+
(Inspector::InjectedScript::callFunctionOn):
160+
(Inspector::InjectedScript::evaluateOnCallFrame):
161+
(Inspector::InjectedScript::getFunctionDetails):
162+
(Inspector::InjectedScript::functionDetails):
163+
(Inspector::InjectedScript::getPreview):
164+
(Inspector::InjectedScript::getProperties):
165+
(Inspector::InjectedScript::getDisplayableProperties):
166+
(Inspector::InjectedScript::getInternalProperties):
167+
(Inspector::InjectedScript::getCollectionEntries):
168+
(Inspector::InjectedScript::saveResult):
169+
(Inspector::InjectedScript::wrapCallFrames const):
170+
(Inspector::InjectedScript::wrapObject const):
171+
(Inspector::InjectedScript::wrapJSONString const):
172+
(Inspector::InjectedScript::wrapTable const):
173+
(Inspector::InjectedScript::previewValue const):
174+
* inspector/InjectedScriptManager.cpp:
175+
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
176+
* inspector/InspectorBackendDispatcher.h:
177+
* inspector/InspectorBackendDispatcher.cpp:
178+
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
179+
(Inspector::BackendDispatcher::dispatch):
180+
(Inspector::BackendDispatcher::sendResponse):
181+
(Inspector::BackendDispatcher::getPropertyValue):
182+
(Inspector::BackendDispatcher::getBoolean):
183+
(Inspector::BackendDispatcher::getInteger):
184+
(Inspector::BackendDispatcher::getDouble):
185+
(Inspector::BackendDispatcher::getString):
186+
(Inspector::BackendDispatcher::getValue):
187+
(Inspector::BackendDispatcher::getObject):
188+
(Inspector::BackendDispatcher::getArray):
189+
(Inspector::castToInteger): Deleted.
190+
(Inspector::castToNumber): Deleted.
191+
* inspector/InspectorProtocolTypes.h:
192+
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
193+
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
194+
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
195+
(Inspector::RemoteInspectorConnectionClient::extractEvent):
196+
* inspector/remote/socket/RemoteInspectorSocket.cpp:
197+
(Inspector::RemoteInspector::pushListingsNow):
198+
* runtime/TypeSet.cpp:
199+
(JSC::StructureShape::inspectorRepresentation):
200+
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
201+
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
202+
to exist.
203+
204+
* inspector/scripts/tests/enum-values.json:
205+
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
206+
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
207+
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
208+
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
209+
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
210+
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
211+
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
212+
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
213+
* inspector/scripts/tests/expected/enum-values.json-result:
214+
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
215+
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
216+
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
217+
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
218+
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
219+
* inspector/scripts/tests/expected/should-strip-comments.json-result:
220+
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
221+
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
222+
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
223+
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
224+
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
225+
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
226+
* inspector/scripts/tests/expected/version.json-result:
227+
1228
2020-09-09 Saam Barati <[email protected]>
2229

3230
OutOfBoundsSaneChain operations should use their own heap locations

Source/JavaScriptCore/bindings/ScriptValue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static RefPtr<JSON::Value> jsToInspectorValue(JSGlobalObject* globalObject, JSVa
6969
auto elementValue = jsToInspectorValue(globalObject, array.getIndex(globalObject, i), maxDepth);
7070
if (!elementValue)
7171
return nullptr;
72-
inspectorArray->pushValue(WTFMove(elementValue));
72+
inspectorArray->pushValue(elementValue.releaseNonNull());
7373
}
7474
return inspectorArray;
7575
}
@@ -82,7 +82,7 @@ static RefPtr<JSON::Value> jsToInspectorValue(JSGlobalObject* globalObject, JSVa
8282
auto inspectorValue = jsToInspectorValue(globalObject, object.get(globalObject, name), maxDepth);
8383
if (!inspectorValue)
8484
return nullptr;
85-
inspectorObject->setValue(name.string(), WTFMove(inspectorValue));
85+
inspectorObject->setValue(name.string(), inspectorValue.releaseNonNull());
8686
}
8787
return inspectorObject;
8888
}

Source/JavaScriptCore/inspector/AsyncStackTrace.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void AsyncStackTrace::didCancelAsyncCall()
9797
m_state = State::Canceled;
9898
}
9999

100-
RefPtr<Protocol::Console::StackTrace> AsyncStackTrace::buildInspectorObject() const
100+
Ref<Protocol::Console::StackTrace> AsyncStackTrace::buildInspectorObject() const
101101
{
102102
RefPtr<Protocol::Console::StackTrace> topStackTrace;
103103
RefPtr<Protocol::Console::StackTrace> previousStackTrace;
@@ -120,13 +120,13 @@ RefPtr<Protocol::Console::StackTrace> AsyncStackTrace::buildInspectorObject() co
120120
topStackTrace = protocolObject.ptr();
121121

122122
if (previousStackTrace)
123-
previousStackTrace->setParentStackTrace(protocolObject.ptr());
123+
previousStackTrace->setParentStackTrace(protocolObject.copyRef());
124124

125125
previousStackTrace = WTFMove(protocolObject);
126126
stackTrace = stackTrace->m_parent.get();
127127
}
128128

129-
return topStackTrace;
129+
return topStackTrace.releaseNonNull();
130130
}
131131

132132
void AsyncStackTrace::truncate(size_t maxDepth)

Source/JavaScriptCore/inspector/AsyncStackTrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class JS_EXPORT_PRIVATE AsyncStackTrace : public RefCounted<AsyncStackTrace> {
5151
void didDispatchAsyncCall();
5252
void didCancelAsyncCall();
5353

54-
RefPtr<Protocol::Console::StackTrace> buildInspectorObject() const;
54+
Ref<Protocol::Console::StackTrace> buildInspectorObject() const;
5555

5656
~AsyncStackTrace();
5757

0 commit comments

Comments
 (0)