Index: Source/core/dom/ScriptElement.cpp |
diff --git a/Source/core/dom/ScriptElement.cpp b/Source/core/dom/ScriptElement.cpp |
index a49e985e0cd71b63074f6e285ed175b32ad3a761..22a1db41c7b0b49f843335ed3055fc1df014bd32 100644 |
--- a/Source/core/dom/ScriptElement.cpp |
+++ b/Source/core/dom/ScriptElement.cpp |
@@ -275,6 +275,11 @@ bool ScriptElement::requestScript(const String& sourceUrl) |
return false; |
} |
+bool isHTMLScriptElement(Element* element) |
+{ |
+ return element->isHTMLElement() && element->hasTagName(HTMLNames::scriptTag); |
abarth-chromium
2013/06/11 17:45:20
The isHTMLElement check isn't redundant with hasTa
|
+} |
+ |
void ScriptElement::executeScript(const ScriptSourceCode& sourceCode) |
{ |
ASSERT(m_alreadyStarted); |
@@ -298,10 +303,19 @@ void ScriptElement::executeScript(const ScriptSourceCode& sourceCode) |
if (frame) { |
{ |
IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(m_isExternalScript ? document.get() : 0); |
+ |
+ if (isHTMLScriptElement(m_element)) |
+ document->pushCurrentScript(static_cast<HTMLScriptElement*>(m_element)); |
abarth-chromium
2013/06/11 17:45:20
We should have a toHTMLScriptElement that contains
|
+ |
// Create a script from the script element node, using the script |
// block's source and the script block's type. |
// Note: This is where the script is compiled and actually executed. |
frame->script()->executeScriptInMainWorld(sourceCode); |
+ |
+ if (isHTMLScriptElement(m_element)) { |
+ ASSERT(document->currentScript() == m_element); |
+ document->popCurrentScript(); |
+ } |
} |
} |
} |
@@ -410,7 +424,7 @@ String ScriptElement::scriptContent() const |
ScriptElement* toScriptElementIfPossible(Element* element) |
{ |
- if (element->isHTMLElement() && element->hasTagName(HTMLNames::scriptTag)) |
+ if (isHTMLScriptElement(element)) |
return static_cast<HTMLScriptElement*>(element); |
if (element->isSVGElement() && element->hasTagName(SVGNames::scriptTag)) |