本文整理汇总了C++中deprecated::ScriptValue类的典型用法代码示例。如果您正苦于以下问题:C++ ScriptValue类的具体用法?C++ ScriptValue怎么用?C++ ScriptValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ScriptValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: jsUndefined
static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecState* exec)
{
const String& typeArg = exec->argument(0).toString(exec)->value(exec);
bool canBubbleArg = exec->argument(1).toBoolean(exec);
bool cancelableArg = exec->argument(2).toBoolean(exec);
const String originArg = exec->argument(4).toString(exec)->value(exec);
const String lastEventIdArg = exec->argument(5).toString(exec)->value(exec);
DOMWindow* sourceArg = toDOMWindow(exec->argument(6));
std::unique_ptr<MessagePortArray> messagePorts;
OwnPtr<ArrayBufferArray> arrayBuffers;
if (!exec->argument(7).isUndefinedOrNull()) {
messagePorts = std::make_unique<MessagePortArray>();
arrayBuffers = adoptPtr(new ArrayBufferArray);
fillMessagePortArray(exec, exec->argument(7), *messagePorts, *arrayBuffers);
if (exec->hadException())
return jsUndefined();
}
Deprecated::ScriptValue dataArg = Deprecated::ScriptValue(exec->vm(), exec->argument(3));
if (exec->hadException())
return jsUndefined();
MessageEvent& event = jsEvent->impl();
event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, sourceArg, WTF::move(messagePorts));
jsEvent->m_data.set(exec->vm(), jsEvent, dataArg.jsValue());
return jsUndefined();
}
开发者ID:CannedFish,项目名称:webkit,代码行数:26,代码来源:JSMessageEventCustom.cpp
示例2: ensureInjected
void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript)
{
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return;
// FIXME: Make the InjectedScript a module itself.
JSC::APIEntryShim entryShim(injectedScript.scriptState());
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), ASCIILiteral("module"), injectedScriptManager->inspectorEnvironment().functionCallHandler());
function.appendArgument(name());
bool hadException = false;
Deprecated::ScriptValue resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) {
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), ASCIILiteral("injectModule"), injectedScriptManager->inspectorEnvironment().functionCallHandler());
function.appendArgument(name());
function.appendArgument(source());
function.appendArgument(host(injectedScriptManager, injectedScript.scriptState()));
resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
if (hadException || (returnsObject() && (resultValue.hasNoValue() || !resultValue.isObject()))) {
ASSERT_NOT_REACHED();
return;
}
}
if (returnsObject()) {
Deprecated::ScriptObject moduleObject(injectedScript.scriptState(), resultValue);
initialize(moduleObject, &injectedScriptManager->inspectorEnvironment());
}
}
开发者ID:boska,项目名称:webkit,代码行数:30,代码来源:InjectedScriptModule.cpp
示例3: ensureInjected
void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript)
{
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return;
// FIXME: Make the InjectedScript a module itself.
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), "module", WebCore::functionCallHandlerFromAnyThread);
function.appendArgument(name());
bool hadException = false;
Deprecated::ScriptValue resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) {
Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), "injectModule", WebCore::functionCallHandlerFromAnyThread);
function.appendArgument(name());
function.appendArgument(source());
function.appendArgument(host(injectedScriptManager, injectedScript.scriptState()));
resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
if (hadException || (returnsObject() && (resultValue.hasNoValue() || !resultValue.isObject()))) {
ASSERT_NOT_REACHED();
return;
}
}
if (returnsObject()) {
Deprecated::ScriptObject moduleObject(injectedScript.scriptState(), resultValue);
initialize(moduleObject, injectedScriptManager->inspectedStateAccessCheck());
}
}
开发者ID:EliBing,项目名称:webkit,代码行数:29,代码来源:InjectedScriptModule.cpp
示例4: evaluate
void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
{
if (isExecutionForbidden())
return;
Deprecated::ScriptValue exception;
evaluate(sourceCode, &exception);
if (exception.jsValue()) {
JSLockHolder lock(vm());
reportException(m_workerGlobalScopeWrapper->globalExec(), exception.jsValue());
}
}
开发者ID:,项目名称:,代码行数:12,代码来源:
示例5: ASSERT
RefPtr<InspectorObject> InspectorDebuggerAgent::buildExceptionPauseReason(const Deprecated::ScriptValue& exception, const InjectedScript& injectedScript)
{
ASSERT(!exception.hasNoValue());
if (exception.hasNoValue())
return nullptr;
ASSERT(!injectedScript.hasNoValue());
if (injectedScript.hasNoValue())
return nullptr;
return injectedScript.wrapObject(exception, InspectorDebuggerAgent::backtraceObjectGroup)->openAccessors();
}
开发者ID:cheekiatng,项目名称:webkit,代码行数:12,代码来源:InspectorDebuggerAgent.cpp
示例6: callWrapContextFunction
Deprecated::ScriptObject InjectedScriptCanvasModule::callWrapContextFunction(const String& functionName, const Deprecated::ScriptObject& context)
{
Deprecated::ScriptFunctionCall function(injectedScriptObject(), functionName, WebCore::functionCallHandlerFromAnyThread);
function.appendArgument(context);
bool hadException = false;
Deprecated::ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException);
if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) {
ASSERT_NOT_REACHED();
return Deprecated::ScriptObject();
}
return Deprecated::ScriptObject(context.scriptState(), resultValue);
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:12,代码来源:InjectedScriptCanvasModule.cpp
示例7: inspectedObject
JSValue JSCommandLineAPIHost::inspectedObject(ExecState* exec)
{
CommandLineAPIHost::InspectableObject* object = impl().inspectedObject();
if (!object)
return jsUndefined();
JSLockHolder lock(exec);
Deprecated::ScriptValue scriptValue = object->get(exec);
if (scriptValue.hasNoValue())
return jsUndefined();
return scriptValue.jsValue();
}
开发者ID:biddyweb,项目名称:switch-oss,代码行数:13,代码来源:JSCommandLineAPIHostCustom.cpp
示例8: getHeapObjectId
void InspectorHeapProfilerAgent::getHeapObjectId(ErrorString* errorString, const String& objectId, String* heapSnapshotObjectId)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue()) {
*errorString = "Inspected context has gone";
return;
}
Deprecated::ScriptValue value = injectedScript.findObjectById(objectId);
if (value.hasNoValue() || value.isUndefined()) {
*errorString = "Object with given id not found";
return;
}
unsigned id = ScriptProfiler::getHeapObjectId(value);
*heapSnapshotObjectId = String::number(id);
}
开发者ID:JefferyJeffery,项目名称:webkit,代码行数:15,代码来源:InspectorHeapProfilerAgent.cpp
示例9: function
PassRefPtr<Array<Inspector::TypeBuilder::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames)
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("wrapCallFrames"), inspectorEnvironment()->functionCallHandler());
function.appendArgument(callFrames);
bool hadException = false;
Deprecated::ScriptValue callFramesValue = callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
RefPtr<InspectorValue> result = callFramesValue.toInspectorValue(scriptState());
if (result->type() == InspectorValue::TypeArray)
return Array<Inspector::TypeBuilder::Debugger::CallFrame>::runtimeCast(result);
return Array<Inspector::TypeBuilder::Debugger::CallFrame>::create();
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:15,代码来源:InjectedScript.cpp
示例10: effectiveObjectStore
RefPtr<WebCore::IDBRequest> IDBCursor::update(JSC::ExecState& exec, Deprecated::ScriptValue& value, ExceptionCode& ec)
{
LOG(IndexedDB, "IDBCursor::update");
if (sourcesDeleted()) {
ec = IDBDatabaseException::InvalidStateError;
return nullptr;
}
if (!transaction().isActive()) {
ec = IDBDatabaseException::TransactionInactiveError;
return nullptr;
}
if (transaction().isReadOnly()) {
ec = IDBDatabaseException::ReadOnlyError;
return nullptr;
}
if (!m_gotValue) {
ec = IDBDatabaseException::InvalidStateError;
return nullptr;
}
if (isKeyCursor()) {
ec = IDBDatabaseException::InvalidStateError;
return nullptr;
}
return effectiveObjectStore().put(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec);
}
开发者ID:sailei1,项目名称:webkit,代码行数:31,代码来源:IDBCursorImpl.cpp
示例11: didPause
void InspectorDebuggerAgent::didPause(JSC::ExecState* scriptState, const Deprecated::ScriptValue& callFrames, const Deprecated::ScriptValue& exception)
{
ASSERT(scriptState && !m_pausedScriptState);
m_pausedScriptState = scriptState;
m_currentCallStack = callFrames;
if (!exception.hasNoValue()) {
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
if (!injectedScript.hasNoValue()) {
m_breakReason = InspectorDebuggerFrontendDispatcher::Reason::Exception;
m_breakAuxData = injectedScript.wrapObject(exception, InspectorDebuggerAgent::backtraceObjectGroup)->openAccessors();
// m_breakAuxData might be null after this.
}
}
m_frontendDispatcher->paused(currentCallFrames(), m_breakReason, m_breakAuxData);
m_javaScriptPauseScheduled = false;
if (m_continueToLocationBreakpointID != JSC::noBreakpointID) {
scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointID);
m_continueToLocationBreakpointID = JSC::noBreakpointID;
}
if (m_listener)
m_listener->didPause();
}
开发者ID:chenbk85,项目名称:webkit2-wincairo,代码行数:26,代码来源:InspectorDebuggerAgent.cpp
示例12: injectIDBKeyIntoScriptValue
bool injectIDBKeyIntoScriptValue(DOMRequestState* requestState, PassRefPtr<IDBKey> key, Deprecated::ScriptValue& value, const IDBKeyPath& keyPath)
{
LOG(StorageAPI, "injectIDBKeyIntoScriptValue");
ASSERT(keyPath.type() == IndexedDB::KeyPathType::String);
Vector<String> keyPathElements;
IDBKeyPathParseError error;
IDBParseKeyPath(keyPath.string(), keyPathElements, error);
ASSERT(error == IDBKeyPathParseError::None);
if (keyPathElements.isEmpty())
return false;
ExecState* exec = requestState->exec();
JSValue parent = ensureNthValueOnKeyPath(exec, value.jsValue(), keyPathElements, keyPathElements.size() - 1);
if (parent.isUndefined())
return false;
if (!set(exec, parent, keyPathElements.last(), idbKeyToJSValue(exec, exec->lexicalGlobalObject(), key.get())))
return false;
return true;
}
开发者ID:valbok,项目名称:WebKitForWayland,代码行数:25,代码来源:IDBBindingUtilities.cpp
示例13: inspectedObject
JSValue JSCommandLineAPIHost::inspectedObject(ExecState* exec)
{
if (exec->argumentCount() < 1)
return jsUndefined();
CommandLineAPIHost::InspectableObject* object = impl().inspectedObject(exec->uncheckedArgument(0).toInt32(exec));
if (!object)
return jsUndefined();
JSLockHolder lock(exec);
Deprecated::ScriptValue scriptValue = object->get(exec);
if (scriptValue.hasNoValue())
return jsUndefined();
return scriptValue.jsValue();
}
开发者ID:CannedFish,项目名称:webkit,代码行数:16,代码来源:JSCommandLineAPIHostCustom.cpp
示例14: wrapFunction
PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const Deprecated::ScriptValue& value, const String& groupName, bool generatePreview) const
{
ASSERT(!hasNoValue());
Deprecated::ScriptFunctionCall wrapFunction(injectedScriptObject(), ASCIILiteral("wrapObject"), inspectorEnvironment()->functionCallHandler());
wrapFunction.appendArgument(value);
wrapFunction.appendArgument(groupName);
wrapFunction.appendArgument(hasAccessToInspectedScriptState());
wrapFunction.appendArgument(generatePreview);
bool hadException = false;
Deprecated::ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException);
if (hadException)
return nullptr;
RefPtr<InspectorObject> rawResult = r.toInspectorValue(scriptState())->asObject();
return Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:17,代码来源:InjectedScript.cpp
示例15: makeCall
void InjectedScriptBase::makeCall(Deprecated::ScriptFunctionCall& function, RefPtr<InspectorValue>* result)
{
if (hasNoValue() || !hasAccessToInspectedScriptState()) {
*result = InspectorValue::null();
return;
}
bool hadException = false;
Deprecated::ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException);
ASSERT(!hadException);
if (!hadException) {
*result = resultValue.toInspectorValue(m_injectedScriptObject.scriptState());
if (!*result)
*result = InspectorString::create(String::format("Object has too long reference chain (must not be longer than %d)", InspectorValue::maxDepth));
} else
*result = InspectorString::create("Exception while making a call.");
}
开发者ID:B-Stefan,项目名称:webkit,代码行数:18,代码来源:InjectedScriptBase.cpp
示例16: data
JSValue JSMessageEvent::data(ExecState* exec) const
{
if (JSValue cachedValue = m_data.get())
return cachedValue;
MessageEvent& event = impl();
JSValue result;
switch (event.dataType()) {
case MessageEvent::DataTypeScriptValue: {
Deprecated::ScriptValue scriptValue = event.dataAsScriptValue();
if (scriptValue.hasNoValue())
result = jsNull();
else
result = scriptValue.jsValue();
break;
}
case MessageEvent::DataTypeSerializedScriptValue:
if (RefPtr<SerializedScriptValue> serializedValue = event.dataAsSerializedScriptValue()) {
MessagePortArray ports = impl().ports();
// FIXME: Why does this suppress exceptions?
result = serializedValue->deserialize(exec, globalObject(), &ports, NonThrowing);
} else
result = jsNull();
break;
case MessageEvent::DataTypeString:
result = jsStringWithCache(exec, event.dataAsString());
break;
case MessageEvent::DataTypeBlob:
result = toJS(exec, globalObject(), event.dataAsBlob());
break;
case MessageEvent::DataTypeArrayBuffer:
result = toJS(exec, globalObject(), event.dataAsArrayBuffer());
break;
}
// Save the result so we don't have to deserialize the value again.
const_cast<JSMessageEvent*>(this)->m_data.set(exec->vm(), this, result);
return result;
}
开发者ID:CannedFish,项目名称:webkit,代码行数:43,代码来源:JSMessageEventCustom.cpp
示例17: executeIfJavaScriptURL
bool ScriptController::executeIfJavaScriptURL(const URL& url, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL)
{
if (!protocolIsJavaScript(url))
return false;
if (!m_frame.page() || !m_frame.document()->contentSecurityPolicy()->allowJavaScriptURLs(m_frame.document()->url(), eventHandlerPosition().m_line))
return true;
// We need to hold onto the Frame here because executing script can
// destroy the frame.
Ref<Frame> protector(m_frame);
RefPtr<Document> ownerDocument(m_frame.document());
const int javascriptSchemeLength = sizeof("javascript:") - 1;
String decodedURL = decodeURLEscapeSequences(url.string());
Deprecated::ScriptValue result = executeScript(decodedURL.substring(javascriptSchemeLength));
// If executing script caused this frame to be removed from the page, we
// don't want to try to replace its document!
if (!m_frame.page())
return true;
String scriptResult;
JSDOMWindowShell* shell = windowShell(mainThreadNormalWorld());
JSC::ExecState* exec = shell->window()->globalExec();
if (!result.getString(exec, scriptResult))
return true;
// FIXME: We should always replace the document, but doing so
// synchronously can cause crashes:
// http://bugs.webkit.org/show_bug.cgi?id=16782
if (shouldReplaceDocumentIfJavaScriptURL == ReplaceDocumentIfJavaScriptURL) {
// We're still in a frame, so there should be a DocumentLoader.
ASSERT(m_frame.document()->loader());
// DocumentWriter::replaceDocument can cause the DocumentLoader to get deref'ed and possible destroyed,
// so protect it with a RefPtr.
if (RefPtr<DocumentLoader> loader = m_frame.document()->loader())
loader->writer().replaceDocument(scriptResult, ownerDocument.get());
}
return true;
}
开发者ID:,项目名称:,代码行数:43,代码来源:
示例18: keyPathKeyData
RefPtr<WebCore::IDBRequest> IDBCursor::update(JSC::ExecState& exec, Deprecated::ScriptValue& value, ExceptionCodeWithMessage& ec)
{
LOG(IndexedDB, "IDBCursor::update");
if (sourcesDeleted()) {
ec.code = IDBDatabaseException::InvalidStateError;
return nullptr;
}
if (!transaction().isActive()) {
ec.code = IDBDatabaseException::TransactionInactiveError;
ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The transaction is inactive or finished.");
return nullptr;
}
if (transaction().isReadOnly()) {
ec.code = IDBDatabaseException::ReadOnlyError;
ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The record may not be updated inside a read-only transaction.");
return nullptr;
}
if (!m_gotValue) {
ec.code = IDBDatabaseException::InvalidStateError;
return nullptr;
}
if (isKeyCursor()) {
ec.code = IDBDatabaseException::InvalidStateError;
ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor is a key cursor.");
return nullptr;
}
auto& objectStore = effectiveObjectStore();
auto& keyPath = objectStore.info().keyPath();
const bool usesInLineKeys = !keyPath.isNull();
if (usesInLineKeys) {
RefPtr<IDBKey> keyPathKey = maybeCreateIDBKeyFromScriptValueAndKeyPath(exec, value, keyPath);
IDBKeyData keyPathKeyData(keyPathKey.get());
if (!keyPathKey || keyPathKeyData != m_currentPrimaryKeyData) {
ec.code = IDBDatabaseException::DataError;
ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key.");
return nullptr;
}
}
auto request = effectiveObjectStore().putForCursorUpdate(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec);
if (ec.code)
return nullptr;
ASSERT(request);
request->setSource(*this);
return request;
}
开发者ID:josedealcala,项目名称:webkit,代码行数:53,代码来源:IDBCursorImpl.cpp
示例19: createIDBKeyFromValue
static RefPtr<IDBKey> internalCreateIDBKeyFromScriptValueAndKeyPath(ExecState* exec, const Deprecated::ScriptValue& value, const String& keyPath)
{
Vector<String> keyPathElements;
IDBKeyPathParseError error;
IDBParseKeyPath(keyPath, keyPathElements, error);
ASSERT(error == IDBKeyPathParseErrorNone);
JSValue jsValue = value.jsValue();
jsValue = getNthValueOnKeyPath(exec, jsValue, keyPathElements, keyPathElements.size());
if (jsValue.isUndefined())
return nullptr;
return createIDBKeyFromValue(exec, jsValue);
}
开发者ID:rodrigo-speller,项目名称:webkit,代码行数:13,代码来源:IDBBindingUtilities.cpp
示例20: importScripts
void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionCode& ec)
{
ASSERT(contentSecurityPolicy());
ec = 0;
Vector<String>::const_iterator urlsEnd = urls.end();
Vector<URL> completedURLs;
for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) {
const URL& url = scriptExecutionContext()->completeURL(*it);
if (!url.isValid()) {
ec = SYNTAX_ERR;
return;
}
completedURLs.append(url);
}
Vector<URL>::const_iterator end = completedURLs.end();
for (Vector<URL>::const_iterator it = completedURLs.begin(); it != end; ++it) {
Ref<WorkerScriptLoader> scriptLoader = WorkerScriptLoader::create();
scriptLoader->loadSynchronously(scriptExecutionContext(), *it, AllowCrossOriginRequests);
// If the fetching attempt failed, throw a NETWORK_ERR exception and abort all these steps.
if (scriptLoader->failed()) {
ec = XMLHttpRequestException::NETWORK_ERR;
return;
}
InspectorInstrumentation::scriptImported(scriptExecutionContext(), scriptLoader->identifier(), scriptLoader->script());
Deprecated::ScriptValue exception;
m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader->responseURL()), &exception);
if (!exception.hasNoValue()) {
m_script->setException(exception);
return;
}
}
}
开发者ID:clbr,项目名称:webkitfltk,代码行数:36,代码来源:WorkerGlobalScope.cpp
注:本文中的deprecated::ScriptValue类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论