Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Unified Diff: Source/core/dom/ScriptElement.cpp

Issue 16682004: Follow up patch for document.currentScript (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ScriptElement.cpp
diff --git a/Source/core/dom/ScriptElement.cpp b/Source/core/dom/ScriptElement.cpp
index 22a1db41c7b0b49f843335ed3055fc1df014bd32..2d470289031c7be61305e77099e6c2b5b2aafde0 100644
--- a/Source/core/dom/ScriptElement.cpp
+++ b/Source/core/dom/ScriptElement.cpp
@@ -277,7 +277,24 @@ bool ScriptElement::requestScript(const String& sourceUrl)
bool isHTMLScriptElement(Element* element)
{
- return element->isHTMLElement() && element->hasTagName(HTMLNames::scriptTag);
+ return element->hasTagName(HTMLNames::scriptTag);
+}
+
+bool isSVGScriptElement(Element* element)
+{
+ return element->hasTagName(SVGNames::scriptTag);
+}
+
+HTMLScriptElement* toHTMLScriptElement(Element* element)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(element->hasTagName(HTMLNames::scriptTag));
+ return static_cast<HTMLScriptElement*>(element);
+}
abarth-chromium 2013/06/11 18:18:23 We usually put these functions in the header that
arv (Not doing code reviews) 2013/06/11 18:44:01 Thanks. I moved these to {HTML,SVG}ScriptElement.h
+
+SVGScriptElement* toSVGScriptElement(Element* element)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(element->hasTagName(SVGNames::scriptTag));
+ return static_cast<SVGScriptElement*>(element);
}
void ScriptElement::executeScript(const ScriptSourceCode& sourceCode)
@@ -305,7 +322,7 @@ void ScriptElement::executeScript(const ScriptSourceCode& sourceCode)
IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountIncrementer(m_isExternalScript ? document.get() : 0);
if (isHTMLScriptElement(m_element))
- document->pushCurrentScript(static_cast<HTMLScriptElement*>(m_element));
+ document->pushCurrentScript(toHTMLScriptElement(m_element));
// Create a script from the script element node, using the script
// block's source and the script block's type.
@@ -425,10 +442,10 @@ String ScriptElement::scriptContent() const
ScriptElement* toScriptElementIfPossible(Element* element)
{
if (isHTMLScriptElement(element))
- return static_cast<HTMLScriptElement*>(element);
+ return toHTMLScriptElement(element);
- if (element->isSVGElement() && element->hasTagName(SVGNames::scriptTag))
- return static_cast<SVGScriptElement*>(element);
+ if (isSVGScriptElement(element))
+ return toSVGScriptElement(element);
return 0;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698