summaryrefslogtreecommitdiffstats
path: root/WebCore/dom/ScriptElement.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-05-26 10:11:43 +0100
committerSteve Block <steveblock@google.com>2010-05-27 11:14:42 +0100
commite78cbe89e6f337f2f1fe40315be88f742b547151 (patch)
treed778000b84a04f24bbad50c7fa66244365e960e9 /WebCore/dom/ScriptElement.cpp
parent7b582e96e4e909ed7dba1e07153d20fbddaec3f7 (diff)
downloadexternal_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.zip
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.gz
external_webkit-e78cbe89e6f337f2f1fe40315be88f742b547151.tar.bz2
Merge WebKit at r60074: Initial merge by git
Change-Id: I18a2dc5439e36c928351ea829d8fb4e39b062fc7
Diffstat (limited to 'WebCore/dom/ScriptElement.cpp')
-rw-r--r--WebCore/dom/ScriptElement.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/WebCore/dom/ScriptElement.cpp b/WebCore/dom/ScriptElement.cpp
index 22d6981..b457f5d 100644
--- a/WebCore/dom/ScriptElement.cpp
+++ b/WebCore/dom/ScriptElement.cpp
@@ -32,9 +32,11 @@
#include "HTMLNames.h"
#include "HTMLScriptElement.h"
#include "MIMETypeRegistry.h"
+#include "Page.h"
#include "ScriptController.h"
#include "ScriptSourceCode.h"
#include "ScriptValue.h"
+#include "Settings.h"
#include "StringHash.h"
#include "Text.h"
#include <wtf/StdLibExtras.h>
@@ -82,12 +84,28 @@ void ScriptElement::childrenChanged(ScriptElementData& data)
data.evaluateScript(ScriptSourceCode(data.scriptContent(), element->document()->url())); // FIXME: Provide a real starting line number here
}
+static inline bool useHTML5Parser(Document* document)
+{
+ ASSERT(document);
+ Settings* settings = document->page() ? document->page()->settings() : 0;
+ return settings && settings->html5ParserEnabled();
+}
+
void ScriptElement::finishParsingChildren(ScriptElementData& data, const String& sourceUrl)
{
// The parser just reached </script>. If we have no src and no text,
// allow dynamic loading later.
if (sourceUrl.isEmpty() && data.scriptContent().isEmpty())
data.setCreatedByParser(false);
+ // HTML5 Requires that we execute scripts from the parser, not from
+ // HTMLTokenizer like we currently do.
+ // FIXME: It may not be safe to execute scripts from here if
+ // HTMLParser::popOneBlockCommon is not reentrant.
+ else if (useHTML5Parser(data.element()->document())) {
+ // This is currently an incomplete implementation, see:
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#parsing-main-incdata
+ data.evaluateScript(ScriptSourceCode(data.scriptContent(), data.element()->document()->url())); // FIXME: Provide a real starting line number here
+ }
}
void ScriptElement::handleSourceAttribute(ScriptElementData& data, const String& sourceUrl)