Web Inspector: InspectorValues should use references for out parameters
https://bugs.webkit.org/show_bug.cgi?id=137190

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

Use references for out parameters in asType() and getType() methods.
Also convert to references in some miscellaneous code where we don't
expect or handle null values.

Remove variants of asObject() and asArray() that return a nullable RefPtr.
Now, client code is forced to use out parameters and check for cast failure.

Iron out control flow in some functions and fix some style issues.

* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::wrapObject):
(Inspector::InjectedScript::wrapTable):
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId): Simplify control flow.
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::InspectorBackendDispatcher::dispatch):
(Inspector::getPropertyValue):
(Inspector::AsMethodBridges::asInteger):
(Inspector::AsMethodBridges::asDouble):
(Inspector::AsMethodBridges::asString):
(Inspector::AsMethodBridges::asBoolean):
(Inspector::AsMethodBridges::asObject):
(Inspector::AsMethodBridges::asArray):
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<Protocol::Array<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<Protocol::Array<T>>::assertValueHasExpectedType):
* inspector/InspectorValues.cpp: Use more by-reference out parameters. Add more spacing.
(Inspector::InspectorValue::asBoolean):
(Inspector::InspectorValue::asDouble):
(Inspector::InspectorValue::asInteger):
(Inspector::InspectorValue::asString):
(Inspector::InspectorValue::asValue):
(Inspector::InspectorValue::asObject):
(Inspector::InspectorValue::asArray):
(Inspector::InspectorValue::parseJSON):
(Inspector::InspectorValue::toJSONString):
(Inspector::InspectorValue::writeJSON):
(Inspector::InspectorBasicValue::asBoolean):
(Inspector::InspectorBasicValue::asDouble):
(Inspector::InspectorBasicValue::asInteger):
(Inspector::InspectorBasicValue::writeJSON):
(Inspector::InspectorString::asString):
(Inspector::InspectorString::writeJSON):
(Inspector::InspectorObjectBase::asObject):
(Inspector::InspectorObjectBase::openAccessors):
(Inspector::InspectorObjectBase::getBoolean):
(Inspector::InspectorObjectBase::getString):
(Inspector::InspectorObjectBase::getObject):
(Inspector::InspectorObjectBase::getArray):
(Inspector::InspectorObjectBase::writeJSON):
(Inspector::InspectorArrayBase::asArray):
(Inspector::InspectorArrayBase::writeJSON):
* inspector/InspectorValues.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::breakpointActionsFromProtocol):
(Inspector::InspectorDebuggerAgent::setBreakpointByUrl):
(Inspector::parseLocation):
(Inspector::InspectorDebuggerAgent::setBreakpoint):
(Inspector::InspectorDebuggerAgent::continueToLocation):
(Inspector::InspectorDebuggerAgent::didParseSource):
* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
* inspector/scripts/codegen/generate_protocol_types_implementation.py:
(ProtocolTypesImplementationGenerator):
(ProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generator_templates.py:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* replay/EncodedValue.cpp:
(JSC::EncodedValue::asObject):
(JSC::EncodedValue::asArray):
(JSC::EncodedValue::convertTo<bool>):
(JSC::EncodedValue::convertTo<double>):
(JSC::EncodedValue::convertTo<float>):
(JSC::EncodedValue::convertTo<int32_t>):
(JSC::EncodedValue::convertTo<int64_t>):
(JSC::EncodedValue::convertTo<uint32_t>):
(JSC::EncodedValue::convertTo<uint64_t>):
(JSC::EncodedValue::convertTo<String>):

Source/WebCore:

Clean up some call sites to explicitly check for cast success, and simplify
some exceptional control flows.

No new tests, no behavior changed.

* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspectImpl):
* inspector/InspectorCSSAgent.cpp:
(WebCore::computePseudoClassMask):
* inspector/InspectorDOMAgent.cpp:
(WebCore::parseColor):
(WebCore::parseConfigColor):
(WebCore::parseQuad):
(WebCore::InspectorDOMAgent::performSearch):
(WebCore::InspectorDOMAgent::highlightConfigFromInspectorObject):
(WebCore::InspectorDOMAgent::innerHighlightQuad):
(WebCore::InspectorDOMAgent::highlightFrame):
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::findStorageArea):
* inspector/InspectorIndexedDBAgent.cpp: Use NeverDestroyed instead of DEPRECATED_DEFINE_STATIC_LOCAL.
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
* inspector/InspectorReplayAgent.cpp:
(WebCore::InspectorReplayAgent::replayToPosition):
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::willSendRequest):
* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::styleWithProperties):
* inspector/InspectorStyleSheet.h:
(WebCore::InspectorCSSId::InspectorCSSId):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::startFromConsole):
(WebCore::InspectorTimelineAgent::stopFromConsole):
* inspector/InspectorWorkerAgent.cpp:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174094 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: InjectedScripts should not be profiled or displayed in Timeline
https://bugs.webkit.org/show_bug.cgi?id=136806

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

It doesn't make sense to show profile nodes for injected scripts when profiling user content.
For now, omit nodes by suspending profiling before and after executing injected scripts.

* profiler/LegacyProfiler.cpp:
(JSC::LegacyProfiler::suspendProfiling): Added.
(JSC::LegacyProfiler::unsuspendProfiling): Added.
* profiler/LegacyProfiler.h:
* profiler/ProfileGenerator.cpp: Add isSuspended() flag, remove unused typedef.
(JSC::ProfileGenerator::ProfileGenerator):
(JSC::ProfileGenerator::willExecute):
(JSC::ProfileGenerator::didExecute):
* profiler/ProfileGenerator.h:
(JSC::ProfileGenerator::setIsSuspended): Added.

Source/WebCore:

Instead of creating timeline records for injected scripts, suspend profiling
of the current page before and after calling injected script functions.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::willCallInjectedScriptFunction):
(WebCore::InspectorController::didCallInjectedScriptFunction):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174095 268f45cc-cd09-0410-ab3c-d52691b4dbfc