当前位置: 首页>>代码示例>>C++>>正文


C++ ScriptSourceCode函数代码示例

本文整理汇总了C++中ScriptSourceCode函数的典型用法代码示例。如果您正苦于以下问题:C++ ScriptSourceCode函数的具体用法?C++ ScriptSourceCode怎么用?C++ ScriptSourceCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ScriptSourceCode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的ScriptSourceCode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。