Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / HTMLScriptElement.cpp
index 0f6df59..6bfccd1 100644 (file)
 #include "core/dom/Attribute.h"
 #include "core/dom/Document.h"
 #include "core/dom/ScriptLoader.h"
+#include "core/dom/ScriptRunner.h"
 #include "core/dom/Text.h"
 #include "core/events/Event.h"
+#include "core/frame/UseCounter.h"
 
 namespace blink {
 
@@ -41,7 +43,6 @@ inline HTMLScriptElement::HTMLScriptElement(Document& document, bool wasInserted
     : HTMLElement(scriptTag, document)
     , m_loader(ScriptLoader::create(this, wasInsertedByParser, alreadyStarted))
 {
-    ScriptWrappable::init(this);
 }
 
 PassRefPtrWillBeRawPtr<HTMLScriptElement> HTMLScriptElement::create(Document& document, bool wasInsertedByParser, bool alreadyStarted)
@@ -70,6 +71,13 @@ void HTMLScriptElement::childrenChanged(const ChildrenChange& change)
     m_loader->childrenChanged();
 }
 
+void HTMLScriptElement::didMoveToNewDocument(Document& oldDocument)
+{
+    if (RefPtrWillBeRawPtr<Document> contextDocument = document().contextDocument().get())
+        oldDocument.scriptRunner()->movePendingAsyncScript(contextDocument->scriptRunner(), m_loader.get());
+    HTMLElement::didMoveToNewDocument(oldDocument);
+}
+
 void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == srcAttr)
@@ -80,6 +88,22 @@ void HTMLScriptElement::parseAttribute(const QualifiedName& name, const AtomicSt
         HTMLElement::parseAttribute(name, value);
 }
 
+void HTMLScriptElement::attributeWillChange(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& newValue)
+{
+    if (name == srcAttr && inDocument()) {
+        V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLoggerIfIsolatedWorld();
+        if (activityLogger) {
+            Vector<String> argv;
+            argv.append("script");
+            argv.append(srcAttr.toString());
+            argv.append(oldValue);
+            argv.append(newValue);
+            activityLogger->logEvent("blinkSetAttribute", argv.size(), argv.data());
+        }
+    }
+    HTMLElement::attributeWillChange(name, oldValue, newValue);
+}
+
 Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode* insertionPoint)
 {
     if (insertionPoint->inDocument()) {
@@ -90,6 +114,9 @@ Node::InsertionNotificationRequest HTMLScriptElement::insertedInto(ContainerNode
             argv.append(fastGetAttribute(srcAttr));
             activityLogger->logEvent("blinkAddElement", argv.size(), argv.data());
         }
+
+        if (hasSourceAttribute() && !loader()->isScriptTypeSupported(ScriptLoader::DisallowLegacyTypeInTypeAttribute))
+            UseCounter::count(document(), UseCounter::ScriptElementWithInvalidTypeHasSrc);
     }
     HTMLElement::insertedInto(insertionPoint);
     return InsertionShouldCallDidNotifySubtreeInsertions;
@@ -185,4 +212,10 @@ PassRefPtrWillBeRawPtr<Element> HTMLScriptElement::cloneElementWithoutAttributes
     return adoptRefWillBeNoop(new HTMLScriptElement(document(), false, m_loader->alreadyStarted()));
 }
 
+void HTMLScriptElement::trace(Visitor* visitor)
+{
+    visitor->trace(m_loader);
+    HTMLElement::trace(visitor);
+}
+
 }