Chromium Code Reviews| Index: Source/core/dom/ScriptElement.cpp |
| diff --git a/Source/core/dom/ScriptElement.cpp b/Source/core/dom/ScriptElement.cpp |
| index 6b5873893dd4efd1916cd66ccff94a1ac14bf5ad..d86592f5e9184a6ca57376160749d05a26c63ee9 100644 |
| --- a/Source/core/dom/ScriptElement.cpp |
| +++ b/Source/core/dom/ScriptElement.cpp |
| @@ -282,6 +282,11 @@ bool ScriptElement::requestScript(const String& sourceUrl) |
| return false; |
| } |
| +bool isHTMLScriptElement(Element* element) |
| +{ |
| + return element->isHTMLElement() && element->hasTagName(HTMLNames::scriptTag); |
| +} |
| + |
| void ScriptElement::executeScript(const ScriptSourceCode& sourceCode) |
| { |
| ASSERT(m_alreadyStarted); |
| @@ -307,10 +312,16 @@ void ScriptElement::executeScript(const ScriptSourceCode& sourceCode) |
| if (frame) { |
| { |
| IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(m_isExternalScript ? document.get() : 0); |
| + |
| + if (isHTMLScriptElement(m_element)) |
| + document->setCurrentScript(static_cast<HTMLScriptElement*>(m_element)); |
| + |
| // 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()->evaluate(sourceCode); |
| + |
| + document->clearCurrentScript(); |
|
esprehn
2013/05/15 16:08:16
You're sure this is safe without checking if (docu
arv (Not doing code reviews)
2013/05/15 16:18:11
There is a case where this will fail. When you doc
|
| } |
| } |
| } |
| @@ -417,7 +428,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 ENABLE(SVG) |