summaryrefslogtreecommitdiffstats
path: root/WebCore/html/parser/HTMLScriptRunner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/html/parser/HTMLScriptRunner.cpp')
-rw-r--r--WebCore/html/parser/HTMLScriptRunner.cpp37
1 files changed, 9 insertions, 28 deletions
diff --git a/WebCore/html/parser/HTMLScriptRunner.cpp b/WebCore/html/parser/HTMLScriptRunner.cpp
index e1fc120..4f54f42 100644
--- a/WebCore/html/parser/HTMLScriptRunner.cpp
+++ b/WebCore/html/parser/HTMLScriptRunner.cpp
@@ -35,6 +35,7 @@
#include "HTMLScriptRunnerHost.h"
#include "HTMLInputStream.h"
#include "HTMLNames.h"
+#include "NestingLevelIncrementer.h"
#include "NotImplemented.h"
#include "ScriptElement.h"
#include "ScriptSourceCode.h"
@@ -43,24 +44,6 @@ namespace WebCore {
using namespace HTMLNames;
-// FIXME: Factor out to avoid duplication with HTMLDocumentParser.
-class NestingLevelIncrementer : public Noncopyable {
-public:
- explicit NestingLevelIncrementer(unsigned& nestingLevel)
- : m_nestingLevel(&nestingLevel)
- {
- ++(*m_nestingLevel);
- }
-
- ~NestingLevelIncrementer()
- {
- --(*m_nestingLevel);
- }
-
-private:
- unsigned* m_nestingLevel;
-};
-
HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* host)
: m_document(document)
, m_host(host)
@@ -155,20 +138,16 @@ void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
if (errorOccurred)
scriptElement->dispatchEvent(createScriptErrorEvent());
else {
- executeScript(scriptElement.get(), sourceCode);
+ executeScript(sourceCode);
scriptElement->dispatchEvent(createScriptLoadEvent());
}
}
ASSERT(!m_scriptNestingLevel);
}
-void HTMLScriptRunner::executeScript(Element* element, const ScriptSourceCode& sourceCode) const
+void HTMLScriptRunner::executeScript(const ScriptSourceCode& sourceCode) const
{
ASSERT(m_document);
- ScriptElement* scriptElement = toScriptElement(element);
- ASSERT(scriptElement);
- if (!scriptElement->shouldExecuteAsJavaScript())
- return;
ASSERT(isExecutingScript());
if (!m_document->frame())
return;
@@ -317,9 +296,11 @@ void HTMLScriptRunner::runScript(Element* script, int startingLineNumber)
InsertionPointRecord insertionPointRecord(m_host->inputStream());
NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
- // Check script type and language, current code uses ScriptElement::shouldExecuteAsJavaScript(), but that may not be HTML5 compliant.
- notImplemented(); // event for support
-
+ ScriptElement* scriptElement = toScriptElement(script);
+ ASSERT(scriptElement);
+ if (!scriptElement->shouldExecuteAsJavaScript())
+ return;
+
if (script->hasAttribute(srcAttr)) {
if (script->hasAttribute(asyncAttr)) // Async takes precendence over defer.
return; // Asynchronous scripts handle themselves.
@@ -335,7 +316,7 @@ void HTMLScriptRunner::runScript(Element* script, int startingLineNumber)
// ASSERT(document()->haveStylesheetsLoaded());
ASSERT(isExecutingScript());
ScriptSourceCode sourceCode(script->textContent(), documentURLForScriptExecution(m_document), startingLineNumber);
- executeScript(script, sourceCode);
+ executeScript(sourceCode);
}
}
}