haikuwebkit/Source/WebCore/dom/InlineClassicScript.cpp

46 lines
1.9 KiB
C++
Raw Permalink Normal View History

Implement InlineClassicScript https://bugs.webkit.org/show_bug.cgi?id=166925 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: Add ScriptFetcher field for SourceOrigin. * runtime/SourceOrigin.h: (JSC::SourceOrigin::SourceOrigin): (JSC::SourceOrigin::fetcher): Source/WebCore: As of r210585, ScriptFetcher functionality is decoupled from ScriptElement. This patch is a further cleanup. We introduce InlineClassicScript, which is similar to LoadableClassicScript / LoadableModuleScript. And we move ScriptFetcher functionality from LoadableScript to CachedScriptFetcher, which is the base class of InlineClassicScript and LoadableScript. And we start setting this CachedScriptFetcher to the member of JSC::SourceOrigin. This allows us to examine the ScriptFetcher from the SourceOrigin. When dynamic-import operator is called, we need to get the ScriptFetcher from the caller script SourceOrigin since the subsequent module loading needs to know the metadata about fetching and ScriptFetcher delivers it. No behavior change. * CMakeLists.txt: * bindings/js/CachedModuleScript.cpp: (WebCore::CachedModuleScript::load): * bindings/js/CachedModuleScript.h: * bindings/js/CachedModuleScriptLoader.cpp: (WebCore::CachedModuleScriptLoader::create): (WebCore::CachedModuleScriptLoader::CachedModuleScriptLoader): (WebCore::CachedModuleScriptLoader::load): * bindings/js/CachedModuleScriptLoader.h: * bindings/js/CachedScriptFetcher.cpp: Copied from Source/WebCore/dom/LoadableScript.cpp. (WebCore::CachedScriptFetcher::requestScriptWithCache): * bindings/js/CachedScriptFetcher.h: Copied from Source/JavaScriptCore/runtime/SourceOrigin.h. (WebCore::CachedScriptFetcher::CachedScriptFetcher): * bindings/js/CachedScriptSourceProvider.h: (WebCore::CachedScriptSourceProvider::create): (WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider): (WebCore::makeSource): Deleted. * bindings/js/ScriptController.cpp: (WebCore::ScriptController::loadModuleScriptInWorld): (WebCore::ScriptController::loadModuleScript): * bindings/js/ScriptController.h: * bindings/js/ScriptModuleLoader.cpp: (WebCore::ScriptModuleLoader::fetch): (WebCore::ScriptModuleLoader::notifyFinished): * bindings/js/ScriptSourceCode.h: (WebCore::ScriptSourceCode::ScriptSourceCode): (WebCore::ScriptSourceCode::m_url): * dom/InlineClassicScript.cpp: Added. (WebCore::InlineClassicScript::create): * dom/InlineClassicScript.h: Added. * dom/LoadableClassicScript.cpp: (WebCore::LoadableClassicScript::execute): * dom/LoadableScript.cpp: (WebCore::LoadableScript::requestScriptWithCache): Deleted. * dom/LoadableScript.h: (WebCore::LoadableScript::LoadableScript): (): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::prepareScript): (WebCore::ScriptElement::requestModuleScript): (WebCore::ScriptElement::executePendingScript): * html/parser/HTMLScriptRunner.cpp: (WebCore::HTMLScriptRunner::runScript): * xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::XMLDocumentParser::endElementNs): Canonical link: https://commits.webkit.org/184067@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-12 09:01:40 +00:00
/*
* Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "InlineClassicScript.h"
#include "Element.h"
#include "ScriptElement.h"
namespace WebCore {
Ref<InlineClassicScript> InlineClassicScript::create(ScriptElement& scriptElement)
{
auto& element = scriptElement.element();
return adoptRef(*new InlineClassicScript(
element.attributeWithoutSynchronization(HTMLNames::nonceAttr),
element.attributeWithoutSynchronization(HTMLNames::crossoriginAttr),
scriptElement.scriptCharset(),
element.localName(),
element.isInUserAgentShadowTree()));
}
}