[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 15:59:32 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f827848dfd5d6356aeca62d85c103bdb38baf78a
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Nov 17 18:56:45 2010 +0000

    2010-11-17  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Darin Adler.
    
            Merge ScriptElement and ScriptElementData
            https://bugs.webkit.org/show_bug.cgi?id=49647
    
            Merged two classes.
    
            * dom/AsyncScriptRunner.cpp:
            (WebCore::AsyncScriptRunner::executeScriptSoon): Takes ScriptElement* instead of ScriptElementData*.
            (WebCore::AsyncScriptRunner::timerFired): Uses ScriptElement* instead of ScriptElementData*.
            * dom/AsyncScriptRunner.h:
            * dom/ScriptElement.cpp:
            (WebCore::ScriptElement::ScriptElement): Merged with ScriptElementData::ScriptElementData.
            (WebCore::ScriptElement::~ScriptElement): Merged with ScriptElementData::~ScriptElementData.
            (WebCore::ScriptElement::insertedIntoDocument): Calls createdByParser, isAsynchronous, requestScript, and scriptContent.
            (WebCore::ScriptElement::removedFromDocument): Calls stopLoadRequest.
            (WebCore::ScriptElement::childrenChanged): Calls createdByParser and accesses m_element.
            (WebCore::ScriptElement::finishParsingChildren): Calls scriptContent.
            (WebCore::ScriptElement::handleSourceAttribute): Calls ignoresLoadRequest and requestScript.
            (WebCore::ScriptElement::requestScript): Moved from ScriptElementData; calls dispatchErrorEvent.
            (WebCore::ScriptElement::evaluateScript): Moved from ScriptElementData.
            (WebCore::ScriptElement::executeScript): Ditto.
            (WebCore::ScriptElement::stopLoadRequest): Ditto.
            (WebCore::ScriptElement::execute): Moved from ScriptElementData; calls dispatchErrorEvent and dispatchLoadEvent.
            (WebCore::ScriptElement::notifyFinished): Moved from ScriptElementData.
            (WebCore::ScriptElement::ignoresLoadRequest): Ditto.
            (WebCore::ScriptElement::shouldExecuteAsJavaScript): Moved from ScriptElementData; calls typeAttributeValue, languageAttributeValue,
            forAttributeValue, and eventAttributeValue.
            (WebCore::ScriptElement::scriptCharset): Moved from ScriptElementData.
            (WebCore::ScriptElement::scriptContent): Ditto.
            (WebCore::ScriptElement::isAsynchronous): Moved from ScriptElementData; calls sourceAttributeValue and asyncAttributeValue.
            (WebCore::ScriptElement::isDeferred): Moved from ScriptElementData; calls sourceAttributeValue, asyncAttributeValue,
            and deferAttributeValue.
            * dom/ScriptElement.h:
            (WebCore::ScriptElement::element):
            (WebCore::ScriptElement::haveFiredLoadEvent):
            (WebCore::ScriptElement::setHaveFiredLoadEvent):
            (WebCore::ScriptElement::createdByParser):
            (WebCore::ScriptElement::isEvaluated):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72222 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7a232a4..68722e1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2010-11-17  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        Merge ScriptElement and ScriptElementData
+        https://bugs.webkit.org/show_bug.cgi?id=49647
+
+        Merged two classes.
+
+        * dom/AsyncScriptRunner.cpp:
+        (WebCore::AsyncScriptRunner::executeScriptSoon): Takes ScriptElement* instead of ScriptElementData*.
+        (WebCore::AsyncScriptRunner::timerFired): Uses ScriptElement* instead of ScriptElementData*.
+        * dom/AsyncScriptRunner.h:
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::ScriptElement): Merged with ScriptElementData::ScriptElementData.
+        (WebCore::ScriptElement::~ScriptElement): Merged with ScriptElementData::~ScriptElementData.
+        (WebCore::ScriptElement::insertedIntoDocument): Calls createdByParser, isAsynchronous, requestScript, and scriptContent.
+        (WebCore::ScriptElement::removedFromDocument): Calls stopLoadRequest.
+        (WebCore::ScriptElement::childrenChanged): Calls createdByParser and accesses m_element.
+        (WebCore::ScriptElement::finishParsingChildren): Calls scriptContent.
+        (WebCore::ScriptElement::handleSourceAttribute): Calls ignoresLoadRequest and requestScript.
+        (WebCore::ScriptElement::requestScript): Moved from ScriptElementData; calls dispatchErrorEvent.
+        (WebCore::ScriptElement::evaluateScript): Moved from ScriptElementData.
+        (WebCore::ScriptElement::executeScript): Ditto.
+        (WebCore::ScriptElement::stopLoadRequest): Ditto.
+        (WebCore::ScriptElement::execute): Moved from ScriptElementData; calls dispatchErrorEvent and dispatchLoadEvent.
+        (WebCore::ScriptElement::notifyFinished): Moved from ScriptElementData.
+        (WebCore::ScriptElement::ignoresLoadRequest): Ditto.
+        (WebCore::ScriptElement::shouldExecuteAsJavaScript): Moved from ScriptElementData; calls typeAttributeValue, languageAttributeValue,
+        forAttributeValue, and eventAttributeValue.
+        (WebCore::ScriptElement::scriptCharset): Moved from ScriptElementData.
+        (WebCore::ScriptElement::scriptContent): Ditto.
+        (WebCore::ScriptElement::isAsynchronous): Moved from ScriptElementData; calls sourceAttributeValue and asyncAttributeValue.
+        (WebCore::ScriptElement::isDeferred): Moved from ScriptElementData; calls sourceAttributeValue, asyncAttributeValue,
+        and deferAttributeValue.
+        * dom/ScriptElement.h:
+        (WebCore::ScriptElement::element):
+        (WebCore::ScriptElement::haveFiredLoadEvent):
+        (WebCore::ScriptElement::setHaveFiredLoadEvent):
+        (WebCore::ScriptElement::createdByParser):
+        (WebCore::ScriptElement::isEvaluated):
+
 2010-11-17  Tenghui Zhu  <ztenghui at google.com>
 
         Reviewed by Jeremy Orlow.
diff --git a/WebCore/dom/AsyncScriptRunner.cpp b/WebCore/dom/AsyncScriptRunner.cpp
index a72df7c..7f5f1b6 100644
--- a/WebCore/dom/AsyncScriptRunner.cpp
+++ b/WebCore/dom/AsyncScriptRunner.cpp
@@ -48,7 +48,7 @@ AsyncScriptRunner::~AsyncScriptRunner()
     }
 }
 
-void AsyncScriptRunner::executeScriptSoon(ScriptElementData* data, CachedResourceHandle<CachedScript> cachedScript)
+void AsyncScriptRunner::executeScriptSoon(ScriptElement* data, CachedResourceHandle<CachedScript> cachedScript)
 {
     ASSERT_ARG(data, data);
 
@@ -80,7 +80,7 @@ void AsyncScriptRunner::timerFired(Timer<AsyncScriptRunner>* timer)
 
     RefPtr<Document> protect(m_document);
     
-    Vector<pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > scripts;
+    Vector<pair<ScriptElement*, CachedResourceHandle<CachedScript> > > scripts;
     scripts.swap(m_scriptsToExecuteSoon);
     size_t size = scripts.size();
     for (size_t i = 0; i < size; ++i) {
diff --git a/WebCore/dom/AsyncScriptRunner.h b/WebCore/dom/AsyncScriptRunner.h
index 57bee84..1a051a8 100644
--- a/WebCore/dom/AsyncScriptRunner.h
+++ b/WebCore/dom/AsyncScriptRunner.h
@@ -36,14 +36,14 @@ namespace WebCore {
 
 class CachedScript;
 class Document;
-class ScriptElementData;
+class ScriptElement;
     
 class AsyncScriptRunner : public Noncopyable {
 public:
     static PassOwnPtr<AsyncScriptRunner> create(Document* document) { return new AsyncScriptRunner(document); }
     ~AsyncScriptRunner();
 
-    void executeScriptSoon(ScriptElementData*, CachedResourceHandle<CachedScript>);
+    void executeScriptSoon(ScriptElement*, CachedResourceHandle<CachedScript>);
     bool hasPendingScripts() const { return !m_scriptsToExecuteSoon.isEmpty(); }
     void suspend();
     void resume();
@@ -54,7 +54,7 @@ private:
     void timerFired(Timer<AsyncScriptRunner>*);
 
     Document* m_document;
-    Vector<std::pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > m_scriptsToExecuteSoon;
+    Vector<std::pair<ScriptElement*, CachedResourceHandle<CachedScript> > > m_scriptsToExecuteSoon;
     Timer<AsyncScriptRunner> m_timer;
 };
 
diff --git a/WebCore/dom/ScriptElement.cpp b/WebCore/dom/ScriptElement.cpp
index d544a09..6c8441d 100644
--- a/WebCore/dom/ScriptElement.cpp
+++ b/WebCore/dom/ScriptElement.cpp
@@ -51,78 +51,72 @@
 
 namespace WebCore {
 
-String ScriptElement::scriptCharset() const
-{
-    return m_data.scriptCharset();
-}
-
-String ScriptElement::scriptContent() const
-{
-    return m_data.scriptContent();
-}
-
-bool ScriptElement::shouldExecuteAsJavaScript() const
+ScriptElement::ScriptElement(Element* element, bool createdByParser, bool isEvaluated)
+    : m_element(element)
+    , m_cachedScript(0)
+    , m_createdByParser(createdByParser)
+    , m_requested(false)
+    , m_isEvaluated(isEvaluated)
+    , m_firedLoad(false)
 {
-    return m_data.shouldExecuteAsJavaScript();
+    ASSERT(m_element);
 }
 
-void ScriptElement::executeScript(const ScriptSourceCode& sourceCode)
+ScriptElement::~ScriptElement()
 {
-    m_data.executeScript(sourceCode);
+    stopLoadRequest();
 }
 
 void ScriptElement::insertedIntoDocument(const String& sourceUrl)
 {
-    if (m_data.createdByParser() && !m_data.isAsynchronous())
+    if (createdByParser() && !isAsynchronous())
         return;
 
     // http://www.whatwg.org/specs/web-apps/current-work/#script
 
     if (!sourceUrl.isEmpty()) {
-        m_data.requestScript(sourceUrl);
+        requestScript(sourceUrl);
         return;
     }
 
     // If there's an empty script node, we shouldn't evaluate the script
     // because if a script is inserted afterwards (by setting text or innerText)
     // it should be evaluated, and evaluateScript only evaluates a script once.
-    m_data.evaluateScript(ScriptSourceCode(m_data.scriptContent(), m_data.element()->document()->url())); // FIXME: Provide a real starting line number here.
+    evaluateScript(ScriptSourceCode(scriptContent(), element()->document()->url())); // FIXME: Provide a real starting line number here.
 }
 
 void ScriptElement::removedFromDocument()
 {
     // Eventually stop loading any not-yet-finished content
-    m_data.stopLoadRequest();
+    stopLoadRequest();
 }
 
 void ScriptElement::childrenChanged()
 {
-    if (m_data.createdByParser())
+    if (createdByParser())
         return;
 
-    Element* element = m_data.element();
-
     // If a node is inserted as a child of the script element
     // and the script element has been inserted in the document
     // we evaluate the script.
-    if (element->inDocument() && element->firstChild())
-        m_data.evaluateScript(ScriptSourceCode(m_data.scriptContent(), element->document()->url())); // FIXME: Provide a real starting line number here
+    if (m_element->inDocument() && m_element->firstChild())
+        evaluateScript(ScriptSourceCode(scriptContent(), m_element->document()->url())); // FIXME: Provide a real starting line number here
 }
 
 void ScriptElement::finishParsingChildren(const String& sourceUrl)
 {
     // The parser just reached </script>. If we have no src and no text,
     // allow dynamic loading later.
-    if (sourceUrl.isEmpty() && m_data.scriptContent().isEmpty())
-        m_data.setCreatedByParser(false);
+    if (sourceUrl.isEmpty() && scriptContent().isEmpty())
+        m_createdByParser = false;
 }
 
 void ScriptElement::handleSourceAttribute(const String& sourceUrl)
 {
-    if (m_data.ignoresLoadRequest() || sourceUrl.isEmpty())
+    if (ignoresLoadRequest() || sourceUrl.isEmpty())
         return;
 
-    m_data.requestScript(sourceUrl);
+    requestScript(sourceUrl);
 }
 
 // Helper function
@@ -149,26 +143,7 @@ static bool isSupportedJavaScriptLanguage(const String& language)
     return languages.contains(language);
 }
 
-// ScriptElementData
-ScriptElementData::ScriptElementData(ScriptElement* scriptElement, Element* element, bool isEvaluated)
-    : m_scriptElement(scriptElement)
-    , m_element(element)
-    , m_cachedScript(0)
-    , m_createdByParser(false)
-    , m_requested(false)
-    , m_isEvaluated(isEvaluated)
-    , m_firedLoad(false)
-{
-    ASSERT(m_scriptElement);
-    ASSERT(m_element);
-}
-
-ScriptElementData::~ScriptElementData()
-{
-    stopLoadRequest();
-}
-
-void ScriptElementData::requestScript(const String& sourceUrl)
+void ScriptElement::requestScript(const String& sourceUrl)
 {
     Document* document = m_element->document();
 
@@ -195,10 +170,10 @@ void ScriptElementData::requestScript(const String& sourceUrl)
         return;
     }
 
-    m_scriptElement->dispatchErrorEvent();
+    dispatchErrorEvent();
 }
 
-void ScriptElementData::evaluateScript(const ScriptSourceCode& sourceCode)
+void ScriptElement::evaluateScript(const ScriptSourceCode& sourceCode)
 {
     if (m_isEvaluated || sourceCode.isEmpty() || !shouldExecuteAsJavaScript())
         return;
@@ -225,7 +200,7 @@ void ScriptElementData::evaluateScript(const ScriptSourceCode& sourceCode)
     }
 }
 
-void ScriptElementData::executeScript(const ScriptSourceCode& sourceCode)
+void ScriptElement::executeScript(const ScriptSourceCode& sourceCode)
 {
     if (m_isEvaluated || sourceCode.isEmpty())
         return;
@@ -240,7 +215,7 @@ void ScriptElementData::executeScript(const ScriptSourceCode& sourceCode)
     frame->script()->executeScript(sourceCode);
 }
 
-void ScriptElementData::stopLoadRequest()
+void ScriptElement::stopLoadRequest()
 {
     if (m_cachedScript) {
         m_cachedScript->removeClient(this);
@@ -248,31 +223,31 @@ void ScriptElementData::stopLoadRequest()
     }
 }
 
-void ScriptElementData::execute(CachedScript* cachedScript)
+void ScriptElement::execute(CachedScript* cachedScript)
 {
     ASSERT(cachedScript);
     if (cachedScript->errorOccurred())
-        m_scriptElement->dispatchErrorEvent();
+        dispatchErrorEvent();
     else {
         evaluateScript(ScriptSourceCode(cachedScript));
-        m_scriptElement->dispatchLoadEvent();
+        dispatchLoadEvent();
     }
     cachedScript->removeClient(this);
 }
 
-void ScriptElementData::notifyFinished(CachedResource* o)
+void ScriptElement::notifyFinished(CachedResource* o)
 {
     ASSERT_UNUSED(o, o == m_cachedScript);
     m_element->document()->asyncScriptRunner()->executeScriptSoon(this, m_cachedScript);
     m_cachedScript = 0;
 }
 
-bool ScriptElementData::ignoresLoadRequest() const
+bool ScriptElement::ignoresLoadRequest() const
 {
     return m_isEvaluated || m_requested || m_createdByParser || !m_element->inDocument();
 }
 
-bool ScriptElementData::shouldExecuteAsJavaScript() const
+bool ScriptElement::shouldExecuteAsJavaScript() const
 {
     /*
          Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts only javascript1.1 - javascript1.3.
@@ -283,20 +258,20 @@ bool ScriptElementData::shouldExecuteAsJavaScript() const
      
          FIXME: Is this HTML5 compliant?
      */
-    String type = m_scriptElement->typeAttributeValue();
+    String type = typeAttributeValue();
     if (!type.isEmpty()) {
         if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace().lower()))
             return false;
     } else {
-        String language = m_scriptElement->languageAttributeValue();
+        String language = languageAttributeValue();
         if (!language.isEmpty() && !isSupportedJavaScriptLanguage(language))
             return false;
     }    
 
     // No type or language is specified, so we assume the script to be JavaScript.
 
-    String forAttribute = m_scriptElement->forAttributeValue();
-    String eventAttribute = m_scriptElement->eventAttributeValue();
+    String forAttribute = forAttributeValue();
+    String eventAttribute = eventAttributeValue();
     if (!forAttribute.isEmpty() && !eventAttribute.isEmpty()) {
         forAttribute = forAttribute.stripWhiteSpace();
         if (!equalIgnoringCase(forAttribute, "window"))
@@ -310,10 +285,10 @@ bool ScriptElementData::shouldExecuteAsJavaScript() const
     return true;
 }
 
-String ScriptElementData::scriptCharset() const
+String ScriptElement::scriptCharset() const
 {
     // First we try to get encoding from charset attribute.
-    String charset = m_scriptElement->charsetAttributeValue().stripWhiteSpace();
+    String charset = charsetAttributeValue().stripWhiteSpace();
 
     // If charset has not been declared in script tag, fall back to frame encoding.
     if (charset.isEmpty()) {
@@ -324,7 +299,7 @@ String ScriptElementData::scriptCharset() const
     return charset;
 }
 
-String ScriptElementData::scriptContent() const
+String ScriptElement::scriptContent() const
 {
     Vector<UChar> val;
     Text* firstTextNode = 0;
@@ -351,18 +326,18 @@ String ScriptElementData::scriptContent() const
     return String::adopt(val);
 }
 
-bool ScriptElementData::isAsynchronous() const
+bool ScriptElement::isAsynchronous() const
 {
     // Only external scripts may be asynchronous.
     // See: http://dev.w3.org/html5/spec/Overview.html#attr-script-async
-    return !m_scriptElement->sourceAttributeValue().isEmpty() && m_scriptElement->asyncAttributeValue();
+    return !sourceAttributeValue().isEmpty() && asyncAttributeValue();
 }
 
-bool ScriptElementData::isDeferred() const
+bool ScriptElement::isDeferred() const
 {
     // Only external scripts may be deferred and async trumps defer to allow for backward compatibility.
     // See: http://dev.w3.org/html5/spec/Overview.html#attr-script-defer
-    return !m_scriptElement->sourceAttributeValue().isEmpty() && !m_scriptElement->asyncAttributeValue() && m_scriptElement->deferAttributeValue();
+    return !sourceAttributeValue().isEmpty() && !asyncAttributeValue() && deferAttributeValue();
 }
 
 ScriptElement* toScriptElement(Element* element)
diff --git a/WebCore/dom/ScriptElement.h b/WebCore/dom/ScriptElement.h
index 3f96ea0..b6beb6e 100644
--- a/WebCore/dom/ScriptElement.h
+++ b/WebCore/dom/ScriptElement.h
@@ -31,60 +31,20 @@ class Element;
 class ScriptElement;
 class ScriptSourceCode;
 
-class ScriptElementData : private CachedResourceClient {
+class ScriptElement : private CachedResourceClient {
 public:
-    ScriptElementData(ScriptElement*, Element*, bool isEvaluated);
-    virtual ~ScriptElementData();
-
-    bool ignoresLoadRequest() const;
-    bool shouldExecuteAsJavaScript() const;
-
-    String scriptContent() const;
-    String scriptCharset() const;
-    bool isAsynchronous() const;
-    bool isDeferred() const;
-    bool isEvaluated() const { return m_isEvaluated; }
-
+    ScriptElement(Element*, bool createdByParser, bool isEvaluated);
+    virtual ~ScriptElement();
+    
     Element* element() const { return m_element; }
-    bool createdByParser() const { return m_createdByParser; }
-    void setCreatedByParser(bool value) { m_createdByParser = value; }
-    bool haveFiredLoadEvent() const { return m_firedLoad; }
-    void setHaveFiredLoadEvent(bool firedLoad) { m_firedLoad = firedLoad; }
-
-    void requestScript(const String& sourceUrl);
-    void evaluateScript(const ScriptSourceCode&);
-    void executeScript(const ScriptSourceCode&);
-    void stopLoadRequest();
-
-    void execute(CachedScript*);
-
-private:
-    virtual void notifyFinished(CachedResource*);
-
-private:
-    ScriptElement* m_scriptElement;
-    Element* m_element;
-    CachedResourceHandle<CachedScript> m_cachedScript;
-    bool m_createdByParser; // HTML5: "parser-inserted"
-    bool m_requested;
-    bool m_isEvaluated; // HTML5: "already started"
-    bool m_firedLoad;
-};
-
-class ScriptElement {
-public:
-    ScriptElement(Element* element, bool createdByParser, bool isEvaluated)
-        : m_data(this, element, isEvaluated)
-    {
-        m_data.setCreatedByParser(createdByParser);
-    }
-    virtual ~ScriptElement() { }
 
     // A charset for loading the script (may be overridden by HTTP headers or a BOM).
     String scriptCharset() const;
+
     String scriptContent() const;
     bool shouldExecuteAsJavaScript() const;
     void executeScript(const ScriptSourceCode&);
+    void execute(CachedScript*);
 
     // XML parser calls these
     virtual String sourceAttributeValue() const = 0;
@@ -92,10 +52,10 @@ public:
     virtual void dispatchErrorEvent() = 0;
 
 protected:
-    bool haveFiredLoadEvent() const { return m_data.haveFiredLoadEvent(); }
-    void setHaveFiredLoadEvent(bool firedLoad) { return m_data.setHaveFiredLoadEvent(firedLoad); }
-    bool createdByParser() const { return m_data.createdByParser(); }
-    bool isEvaluated() const { return m_data.isEvaluated(); }
+    bool haveFiredLoadEvent() const { return m_firedLoad; }
+    void setHaveFiredLoadEvent(bool firedLoad) { m_firedLoad = firedLoad; }
+    bool createdByParser() const { return m_createdByParser; }
+    bool isEvaluated() const { return m_isEvaluated; }
 
     // Helper functions used by our parent classes.
     void insertedIntoDocument(const String& sourceUrl);
@@ -105,6 +65,16 @@ protected:
     void handleSourceAttribute(const String& sourceUrl);
 
 private:
+    bool ignoresLoadRequest() const;
+    bool isAsynchronous() const;
+    bool isDeferred() const;
+
+    void requestScript(const String& sourceUrl);
+    void evaluateScript(const ScriptSourceCode&);
+    void stopLoadRequest();
+
+    virtual void notifyFinished(CachedResource*);
+
     virtual String charsetAttributeValue() const = 0;
     virtual String typeAttributeValue() const = 0;
     virtual String languageAttributeValue() const = 0;
@@ -113,9 +83,12 @@ private:
     virtual bool asyncAttributeValue() const = 0;
     virtual bool deferAttributeValue() const = 0;
 
-    friend class ScriptElementData;
-
-    ScriptElementData m_data;
+    Element* m_element;
+    CachedResourceHandle<CachedScript> m_cachedScript;
+    bool m_createdByParser; // HTML5: "parser-inserted"
+    bool m_requested;
+    bool m_isEvaluated; // HTML5: "already started"
+    bool m_firedLoad;
 };
 
 ScriptElement* toScriptElement(Element*);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list