本文整理汇总了C++中ScriptSourceCode函数的典型用法代码示例。如果您正苦于以下问题:C++ ScriptSourceCode函数的具体用法?C++ ScriptSourceCode怎么用?C++ ScriptSourceCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ScriptSourceCode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: scriptString
void XMLTreeViewer::transformDocumentToTreeView()
{
m_document->setIsViewSource(true);
String scriptString(reinterpret_cast<const char*>(XMLViewer_js), sizeof(XMLViewer_js));
m_document->frame()->script()->executeScriptInMainWorld(ScriptSourceCode(scriptString));
String noStyleMessage("This XML file does not appear to have any style information associated with it. The document tree is shown below.");
m_document->frame()->script()->executeScriptInMainWorld(ScriptSourceCode("prepareWebKitXMLViewer('" + noStyleMessage + "');"));
String cssString(reinterpret_cast<const char*>(XMLViewer_css), sizeof(XMLViewer_css));
RefPtr<Text> text = m_document->createTextNode(cssString);
m_document->getElementById("xml-viewer-style")->appendChild(text, IGNORE_EXCEPTION);
}
开发者ID:huningxin,项目名称:blink-crosswalk,代码行数:12,代码来源:XMLTreeViewer.cpp
示例2: resource
ScriptSourceCode PendingScript::getSource(const KURL& documentURL, bool& errorOccurred) const
{
if (resource()) {
errorOccurred = resource()->errorOccurred() || m_integrityFailure;
ASSERT(resource()->isLoaded());
if (m_streamer && !m_streamer->streamingSuppressed())
return ScriptSourceCode(m_streamer, resource());
return ScriptSourceCode(resource());
}
errorOccurred = false;
return ScriptSourceCode(m_element->textContent(), documentURL, startingPosition());
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:12,代码来源:PendingScript.cpp
示例3: sizeof
void XMLTreeViewer::transformDocumentToTreeView()
{
m_document.setSecurityOriginPolicy(SecurityOriginPolicy::create(SecurityOrigin::createUnique()));
String scriptString = StringImpl::createWithoutCopying(XMLViewer_js, sizeof(XMLViewer_js));
m_document.frame()->script().evaluate(ScriptSourceCode(scriptString));
m_document.frame()->script().evaluate(ScriptSourceCode(AtomicString("prepareWebKitXMLViewer('This XML file does not appear to have any style information associated with it. The document tree is shown below.');")));
String cssString = StringImpl::createWithoutCopying(XMLViewer_css, sizeof(XMLViewer_css));
Ref<Text> text = m_document.createTextNode(cssString);
m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(WTFMove(text), IGNORE_EXCEPTION);
m_document.styleResolverChanged(RecalcStyleImmediately);
}
开发者ID:quanmo,项目名称:webkit,代码行数:13,代码来源:XMLTreeViewer.cpp
示例4: scriptString
void XMLTreeViewer::transformDocumentToTreeView()
{
String scriptString(reinterpret_cast<const char*>(XMLViewer_js), sizeof(XMLViewer_js));
m_document->frame()->script()->evaluate(ScriptSourceCode(scriptString));
String noStyleMessage("This XML file does not appear to have any style information associated with it. The document tree is shown below.");
m_document->frame()->script()->evaluate(ScriptSourceCode("prepareWebKitXMLViewer('" + noStyleMessage + "');"));
String cssString(reinterpret_cast<const char*>(XMLViewer_css), sizeof(XMLViewer_css));
RefPtr<Text> text = m_document->createTextNode(cssString);
ExceptionCode exceptionCode;
m_document->getElementById("xml-viewer-style")->appendChild(text, exceptionCode);
m_document->setUsesViewSourceStyles(true);
m_document->styleSelectorChanged(RecalcStyleImmediately);
}
开发者ID:dankurka,项目名称:webkit_titanium,代码行数:15,代码来源:XMLTreeViewer.cpp
示例5: scriptExecutionContext
void WorkerContext::importScripts(const Vector<String>& urls, ExceptionCode& ec)
{
ec = 0;
Vector<String>::const_iterator urlsEnd = urls.end();
Vector<KURL> completedURLs;
for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) {
const KURL& url = scriptExecutionContext()->completeURL(*it);
if (!url.isValid()) {
ec = SYNTAX_ERR;
return;
}
completedURLs.append(url);
}
Vector<KURL>::const_iterator end = completedURLs.end();
for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++it) {
WorkerScriptLoader scriptLoader(ResourceRequestBase::TargetIsScript);
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());
ScriptValue exception;
m_script->evaluate(ScriptSourceCode(scriptLoader.script(), scriptLoader.responseURL()), &exception);
if (!exception.hasNoValue()) {
m_script->setException(exception);
return;
}
}
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:35,代码来源:WorkerContext.cpp
示例6: ASSERT
void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionCode& ec)
{
ASSERT(contentSecurityPolicy());
ec = 0;
Vector<URL> completedURLs;
for (auto& entry : urls) {
URL url = scriptExecutionContext()->completeURL(entry);
if (!url.isValid()) {
ec = SYNTAX_ERR;
return;
}
completedURLs.append(WTFMove(url));
}
for (auto& url : completedURLs) {
Ref<WorkerScriptLoader> scriptLoader = WorkerScriptLoader::create();
scriptLoader->loadSynchronously(scriptExecutionContext(), url, AllowCrossOriginRequests);
// If the fetching attempt failed, throw a NETWORK_ERR exception and abort all these steps.
if (scriptLoader->failed()) {
ec = NETWORK_ERR;
return;
}
InspectorInstrumentation::scriptImported(scriptExecutionContext(), scriptLoader->identifier(), scriptLoader->script());
NakedPtr<JSC::Exception> exception;
m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader->responseURL()), exception);
if (exception) {
m_script->setException(exception);
return;
}
}
}
开发者ID:shenangovalleyavclub,项目名称:webkit,代码行数:34,代码来源:WorkerGlobalScope.cpp
示例7: lock
void* WorkerThread::workerThread()
{
{
MutexLocker lock(m_threadCreationMutex);
m_workerContext = createWorkerContext(m_startupData->m_scriptURL, m_startupData->m_userAgent);
if (m_runLoop.terminated()) {
// The worker was terminated before the thread had a chance to run. Since the context didn't exist yet,
// forbidExecution() couldn't be called from stop().
m_workerContext->script()->forbidExecution();
}
}
WorkerScriptController* script = m_workerContext->script();
script->evaluate(ScriptSourceCode(m_startupData->m_sourceCode, m_startupData->m_scriptURL));
// Free the startup data to cause its member variable deref's happen on the worker's thread (since
// all ref/derefs of these objects are happening on the thread at this point). Note that
// WorkerThread::~WorkerThread happens on a different thread where it was created.
m_startupData.clear();
runEventLoop();
ThreadIdentifier threadID = m_threadID;
ASSERT(m_workerContext->hasOneRef());
// The below assignment will destroy the context, which will in turn notify messaging proxy.
// We cannot let any objects survive past thread exit, because no other thread will run GC or otherwise destroy them.
m_workerContext = 0;
// The thread object may be already destroyed from notification now, don't try to access "this".
detachThread(threadID);
return 0;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:35,代码来源:WorkerThread.cpp
示例8: executeScriptInWorker
void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent)
{
WorkerOrWorkletScriptController* scriptController = worker->workerGlobalScope()->scriptController();
bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var counter = 0; ++counter;"));
ASSERT_UNUSED(evaluateResult, evaluateResult);
waitEvent->signal();
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:7,代码来源:CompositorWorkerThreadTest.cpp
示例9: overlayPage
void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<InspectorValue> argument)
{
RefPtr<InspectorArray> command = InspectorArray::create();
command->pushString(method);
command->pushValue(argument);
overlayPage()->mainFrame().script().evaluate(ScriptSourceCode(makeString("dispatch(", command->toJSONString(), ")")));
}
开发者ID:aosm,项目名称:WebCore,代码行数:7,代码来源:InspectorOverlay.cpp
示例10: scope
void InspectorClient::doDispatchMessageOnFrontendPage(Page* frontendPage, const String& message)
{
if (!frontendPage)
return;
SuspendExceptionScope scope(&frontendPage->inspectorController().vm());
String dispatchToFrontend = makeString("InspectorFrontendAPI.dispatchMessageAsync(", message, ");");
frontendPage->mainFrame().script().evaluate(ScriptSourceCode(dispatchToFrontend));
}
开发者ID:eocanha,项目名称:webkit,代码行数:9,代码来源:InspectorClient.cpp
示例11: ASSERT
void ScriptElementData::execute(CachedScript* cachedScript)
{
ASSERT(cachedScript);
if (cachedScript->errorOccurred())
m_scriptElement->dispatchErrorEvent();
else {
evaluateScript(ScriptSourceCode(cachedScript));
m_scriptElement->dispatchLoadEvent();
}
cachedScript->removeClient(this);
}
开发者ID:ShouqingZhang,项目名称:webkitdriver,代码行数:11,代码来源:ScriptElement.cpp
示例12: scope
void ScriptController::collectGarbage()
{
v8::HandleScope handleScope;
v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(m_proxy->frame());
if (v8Context.IsEmpty())
return;
v8::Context::Scope scope(v8Context);
m_proxy->evaluate(ScriptSourceCode("if (window.gc) void(gc());"), 0);
}
开发者ID:matthiasbock,项目名称:Samsung-GT-S6102-platform,代码行数:11,代码来源:ScriptController.cpp
示例13: ASSERT
void ScriptElement::execute(CachedScript* cachedScript)
{
ASSERT(!m_willBeParserExecuted);
ASSERT(cachedScript);
if (cachedScript->errorOccurred())
dispatchErrorEvent();
else if (!cachedScript->wasCanceled()) {
executeScript(ScriptSourceCode(cachedScript));
dispatchLoadEvent();
}
cachedScript->removeClient(this);
}
开发者ID:Spencerx,项目名称:webkit,代码行数:12,代码来源:ScriptElement.cpp
示例14: PLATFORM
void WorkerThread::workerThread()
{
// Propagate the mainThread's fenv to workers.
#if PLATFORM(IOS)
FloatingPointEnvironment::singleton().propagateMainThreadEnvironment();
#endif
#if PLATFORM(GTK)
GRefPtr<GMainContext> mainContext = adoptGRef(g_main_context_new());
g_main_context_push_thread_default(mainContext.get());
#endif
{
LockHolder lock(m_threadCreationMutex);
m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_contentSecurityPolicyResponseHeaders, m_startupData->m_shouldBypassMainWorldContentSecurityPolicy, WTFMove(m_startupData->m_topOrigin));
if (m_runLoop.terminated()) {
// The worker was terminated before the thread had a chance to run. Since the context didn't exist yet,
// forbidExecution() couldn't be called from stop().
m_workerGlobalScope->script()->forbidExecution();
}
}
WorkerScriptController* script = m_workerGlobalScope->script();
script->evaluate(ScriptSourceCode(m_startupData->m_sourceCode, m_startupData->m_scriptURL));
// Free the startup data to cause its member variable deref's happen on the worker's thread (since
// all ref/derefs of these objects are happening on the thread at this point). Note that
// WorkerThread::~WorkerThread happens on a different thread where it was created.
m_startupData = nullptr;
runEventLoop();
#if PLATFORM(GTK)
g_main_context_pop_thread_default(mainContext.get());
#endif
ThreadIdentifier threadID = m_threadID;
ASSERT(m_workerGlobalScope->hasOneRef());
// The below assignment will destroy the context, which will in turn notify messaging proxy.
// We cannot let any objects survive past thread exit, because no other thread will run GC or otherwise destroy them.
m_workerGlobalScope = nullptr;
// Clean up WebCore::ThreadGlobalData before WTF::WTFThreadData goes away!
threadGlobalData().destroy();
// The thread object may be already destroyed from notification now, don't try to access "this".
detachThread(threadID);
}
开发者ID:endlessm,项目名称:WebKit,代码行数:50,代码来源:WorkerThread.cpp
示例15: ASCIILiteral
void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr<DeferredPromise> promise)
{
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script
if (!m_loaders.remove(&loader))
return;
loader.clearClient();
auto& cachedScript = *loader.cachedScript();
bool failed = false;
if (cachedScript.resourceError().isAccessControl()) {
promise->reject(TypeError, ASCIILiteral("Cross-origin script load denied by Cross-Origin Resource Sharing policy."));
return;
}
if (cachedScript.errorOccurred())
failed = true;
else if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(cachedScript.response().mimeType())) {
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script
// The result of extracting a MIME type from response's header list (ignoring parameters) is not a JavaScript MIME type.
// For historical reasons, fetching a classic script does not include MIME type checking. In contrast, module scripts will fail to load if they are not of a correct MIME type.
promise->reject(TypeError, makeString("'", cachedScript.response().mimeType(), "' is not a valid JavaScript MIME type."));
return;
}
auto* frame = m_document.frame();
if (!frame)
return;
if (failed) {
// Reject a promise to propagate the error back all the way through module promise chains to the script element.
promise->reject(frame->script().moduleLoaderAlreadyReportedErrorSymbol());
return;
}
if (cachedScript.wasCanceled()) {
promise->reject(frame->script().moduleLoaderFetchingIsCanceledSymbol());
return;
}
m_requestURLToResponseURLMap.add(cachedScript.url(), cachedScript.response().url());
// FIXME: Let's wrap around ScriptSourceCode to propagate it directly through the module pipeline.
promise->resolve<IDLDOMString>(ScriptSourceCode(&cachedScript, JSC::SourceProviderSourceType::Module).source().toString());
}
开发者ID:eocanha,项目名称:webkit,代码行数:46,代码来源:ScriptModuleLoader.cpp
示例16: TRACE_EVENT0
void ScheduledAction::execute(LocalFrame* frame)
{
if (m_scriptState->contextIsEmpty())
return;
TRACE_EVENT0("v8", "ScheduledAction::execute");
ScriptState::Scope scope(m_scriptState.get());
if (!m_function.isEmpty()) {
Vector<v8::Handle<v8::Value> > info;
createLocalHandlesForArgs(&info);
frame->script().callFunction(m_function.newLocal(m_scriptState->isolate()), m_scriptState->context()->Global(), info.size(), info.data());
} else {
frame->script().executeScriptAndReturnValue(m_scriptState->context(), ScriptSourceCode(m_code));
}
// The frame might be invalid at this point because JavaScript could have released it.
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:17,代码来源:ScheduledAction.cpp
示例17: ASSERT
void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState& exceptionState)
{
ASSERT(contentSecurityPolicy());
ASSERT(getExecutionContext());
ExecutionContext& executionContext = *this->getExecutionContext();
Vector<KURL> completedURLs;
for (const String& urlString : urls) {
const KURL& url = executionContext.completeURL(urlString);
if (!url.isValid()) {
exceptionState.throwDOMException(SyntaxError, "The URL '" + urlString + "' is invalid.");
return;
}
if (!contentSecurityPolicy()->allowScriptFromSource(url)) {
exceptionState.throwDOMException(NetworkError, "The script at '" + url.elidedString() + "' failed to load.");
return;
}
completedURLs.append(url);
}
for (const KURL& completeURL : completedURLs) {
RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create());
scriptLoader->setRequestContext(WebURLRequest::RequestContextScript);
scriptLoader->loadSynchronously(executionContext, completeURL, AllowCrossOriginRequests, executionContext.securityContext().addressSpace());
// If the fetching attempt failed, throw a NetworkError exception and abort all these steps.
if (scriptLoader->failed()) {
exceptionState.throwDOMException(NetworkError, "The script at '" + completeURL.elidedString() + "' failed to load.");
return;
}
InspectorInstrumentation::scriptImported(&executionContext, scriptLoader->identifier(), scriptLoader->script());
scriptLoaded(scriptLoader->script().length(), scriptLoader->cachedMetadata() ? scriptLoader->cachedMetadata()->size() : 0);
RawPtr<ErrorEvent> errorEvent = nullptr;
OwnPtr<Vector<char>> cachedMetaData(scriptLoader->releaseCachedMetadata());
RawPtr<CachedMetadataHandler> handler(createWorkerScriptCachedMetadataHandler(completeURL, cachedMetaData.get()));
m_scriptController->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader->responseURL()), &errorEvent, handler.get(), m_v8CacheOptions);
if (errorEvent) {
m_scriptController->rethrowExceptionFromImportedScript(errorEvent.release(), exceptionState);
return;
}
}
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:45,代码来源:WorkerGlobalScope.cpp
示例18: ASSERT
void ScriptElementData::notifyFinished(CachedResource* o)
{
CachedScript* cs = static_cast<CachedScript*>(o);
ASSERT(cs == m_cachedScript);
// Evaluating the script could lead to a garbage collection which can
// delete the script element so we need to protect it and us with it!
RefPtr<Element> protector(m_element);
if (cs->errorOccurred())
m_scriptElement->dispatchErrorEvent();
else {
evaluateScript(ScriptSourceCode(cs));
m_scriptElement->dispatchLoadEvent();
}
stopLoadRequest();
}
开发者ID:arjunroy,项目名称:cinder_webkit,代码行数:18,代码来源:ScriptElement.cpp
示例19: PLATFORM
void WorkerThread::workerThread()
{
// Propagate the mainThread's fenv to workers.
#if PLATFORM(IOS)
fesetenv(&mainThreadFEnv);
#endif
{
MutexLocker lock(m_threadCreationMutex);
m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, m_startupData->m_userAgent, std::move(m_startupData->m_groupSettings), m_startupData->m_contentSecurityPolicy, m_startupData->m_contentSecurityPolicyType, m_startupData->m_topOrigin.release());
if (m_runLoop.terminated()) {
// The worker was terminated before the thread had a chance to run. Since the context didn't exist yet,
// forbidExecution() couldn't be called from stop().
m_workerGlobalScope->script()->forbidExecution();
}
}
WorkerScriptController* script = m_workerGlobalScope->script();
#if ENABLE(INSPECTOR)
InspectorInstrumentation::willEvaluateWorkerScript(workerGlobalScope(), m_startupData->m_startMode);
#endif
script->evaluate(ScriptSourceCode(m_startupData->m_sourceCode, m_startupData->m_scriptURL));
// Free the startup data to cause its member variable deref's happen on the worker's thread (since
// all ref/derefs of these objects are happening on the thread at this point). Note that
// WorkerThread::~WorkerThread happens on a different thread where it was created.
m_startupData.clear();
runEventLoop();
ThreadIdentifier threadID = m_threadID;
ASSERT(m_workerGlobalScope->hasOneRef());
// The below assignment will destroy the context, which will in turn notify messaging proxy.
// We cannot let any objects survive past thread exit, because no other thread will run GC or otherwise destroy them.
m_workerGlobalScope = 0;
// Clean up WebCore::ThreadGlobalData before WTF::WTFThreadData goes away!
threadGlobalData().destroy();
// The thread object may be already destroyed from notification now, don't try to access "this".
detachThread(threadID);
}
开发者ID:boska,项目名称:webkit,代码行数:44,代码来源:WorkerThread.cpp
示例20: onFinished
void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver* resolver)
{
if (scriptLoader->failed()) {
resolver->reject(DOMException::create(NetworkError));
} else {
// TODO(ikilpatrick): Worklets don't have the same error behaviour
// as workers, etc. For a SyntaxError we should reject, however if
// the script throws a normal error, resolve. For now just resolve.
m_workletGlobalScope->scriptController()->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader->url()));
resolver->resolve();
}
size_t index = m_scriptLoaders.find(scriptLoader);
ASSERT(index != kNotFound);
ASSERT(m_resolvers[index] == resolver);
m_scriptLoaders.remove(index);
m_resolvers.remove(index);
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:20,代码来源:Worklet.cpp
注:本文中的ScriptSourceCode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论