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

zimmermann at webkit.org zimmermann at webkit.org
Wed Dec 22 11:37:36 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 15d93e0e16a4d7b5276d97c4ca61ffd766b073c5
Author: zimmermann at webkit.org <zimmermann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Jul 31 17:30:54 2010 +0000

    2010-07-31  Nikolas Zimmermann  <nzimmermann at rim.com>
    
            Reviewed by Dirk Schulze.
    
            HTMLStyleElement/SVGStyleElement need to share more code
            https://bugs.webkit.org/show_bug.cgi?id=43293
    
            Simplify HTMLStyleElement/SVGStyleElement. They look identically now, as all code is shared in StyleElement.
            Doesn't affect any tests.
    
            * dom/StyleElement.cpp:
            (WebCore::StyleElement::StyleElement): Take createdByParser & Document arguments, to share the line number extraction logic. Store it in m_lineNumber.
            (WebCore::StyleElement::insertedIntoDocument): Moved addStyleSheetCandidateNode here, to share code between HTML/SVGStyleElement.
            (WebCore::StyleElement::removedFromDocument): Same for removeStyleSheetCandidateNode.
            (WebCore::StyleElement::childrenChanged): Introduced new helper function.
            (WebCore::StyleElement::finishParsingChildren): Ditto.
            (WebCore::StyleElement::process): Use stored m_lineNumber, avoids a parameter.
            (WebCore::StyleElement::createSheet): No need to call the virtual setLoading() function, just store m_loading in StyleElement, and set it from here.
            (WebCore::StyleElement::isLoading): Introduced new helper function.
            (WebCore::StyleElement::sheetLoaded): Ditto.
            * dom/StyleElement.h:
            * html/HTMLStyleElement.cpp:
            (WebCore::HTMLStyleElement::HTMLStyleElement): Pass Document & createdByParser arguments to StyleElement.
            (WebCore::HTMLStyleElement::finishParsingChildren): Delegate work to StyleElement.
            (WebCore::HTMLStyleElement::insertedIntoDocument): Ditto.
            (WebCore::HTMLStyleElement::removedFromDocument): Ditto.
            (WebCore::HTMLStyleElement::childrenChanged): Ditto.
            * html/HTMLStyleElement.h:
            (WebCore::HTMLStyleElement::isLoading): Ditto.
            (WebCore::HTMLStyleElement::sheetLoaded): Ditto.
            * svg/SVGStyleElement.cpp:
            (WebCore::SVGStyleElement::SVGStyleElement): Pass Document & createdByParser arguments to StyleElement.
            (WebCore::SVGStyleElement::finishParsingChildren): Delegate work to StyleElement.
            (WebCore::SVGStyleElement::insertedIntoDocument): Ditto.
            (WebCore::SVGStyleElement::removedFromDocument): Ditto.
            (WebCore::SVGStyleElement::childrenChanged): Ditto.
            * svg/SVGStyleElement.h:
            (WebCore::SVGStyleElement::isLoading): Ditto.
            (WebCore::SVGStyleElement::sheetLoaded): Ditto.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64420 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0e6e852..b213b5c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,43 @@
+2010-07-31  Nikolas Zimmermann  <nzimmermann at rim.com>
+
+        Reviewed by Dirk Schulze.
+
+        HTMLStyleElement/SVGStyleElement need to share more code
+        https://bugs.webkit.org/show_bug.cgi?id=43293
+
+        Simplify HTMLStyleElement/SVGStyleElement. They look identically now, as all code is shared in StyleElement.
+        Doesn't affect any tests.
+
+        * dom/StyleElement.cpp:
+        (WebCore::StyleElement::StyleElement): Take createdByParser & Document arguments, to share the line number extraction logic. Store it in m_lineNumber.
+        (WebCore::StyleElement::insertedIntoDocument): Moved addStyleSheetCandidateNode here, to share code between HTML/SVGStyleElement.
+        (WebCore::StyleElement::removedFromDocument): Same for removeStyleSheetCandidateNode.
+        (WebCore::StyleElement::childrenChanged): Introduced new helper function.
+        (WebCore::StyleElement::finishParsingChildren): Ditto.
+        (WebCore::StyleElement::process): Use stored m_lineNumber, avoids a parameter.
+        (WebCore::StyleElement::createSheet): No need to call the virtual setLoading() function, just store m_loading in StyleElement, and set it from here.
+        (WebCore::StyleElement::isLoading): Introduced new helper function.
+        (WebCore::StyleElement::sheetLoaded): Ditto.
+        * dom/StyleElement.h:
+        * html/HTMLStyleElement.cpp:
+        (WebCore::HTMLStyleElement::HTMLStyleElement): Pass Document & createdByParser arguments to StyleElement.
+        (WebCore::HTMLStyleElement::finishParsingChildren): Delegate work to StyleElement.
+        (WebCore::HTMLStyleElement::insertedIntoDocument): Ditto.
+        (WebCore::HTMLStyleElement::removedFromDocument): Ditto.
+        (WebCore::HTMLStyleElement::childrenChanged): Ditto.
+        * html/HTMLStyleElement.h:
+        (WebCore::HTMLStyleElement::isLoading): Ditto.
+        (WebCore::HTMLStyleElement::sheetLoaded): Ditto.
+        * svg/SVGStyleElement.cpp:
+        (WebCore::SVGStyleElement::SVGStyleElement): Pass Document & createdByParser arguments to StyleElement.
+        (WebCore::SVGStyleElement::finishParsingChildren): Delegate work to StyleElement.
+        (WebCore::SVGStyleElement::insertedIntoDocument): Ditto.
+        (WebCore::SVGStyleElement::removedFromDocument): Ditto.
+        (WebCore::SVGStyleElement::childrenChanged): Ditto.
+        * svg/SVGStyleElement.h:
+        (WebCore::SVGStyleElement::isLoading): Ditto.
+        (WebCore::SVGStyleElement::sheetLoaded): Ditto.
+
 2010-07-31  Kinuko Yasuda  <kinuko at chromium.org>
 
         Unreviewed.  Attempt to fix release build failure.
diff --git a/WebCore/dom/StyleElement.cpp b/WebCore/dom/StyleElement.cpp
index 580f318..4c0e56f 100644
--- a/WebCore/dom/StyleElement.cpp
+++ b/WebCore/dom/StyleElement.cpp
@@ -26,11 +26,17 @@
 #include "Element.h"
 #include "MediaList.h"
 #include "MediaQueryEvaluator.h"
+#include "ScriptableDocumentParser.h"
 
 namespace WebCore {
 
-StyleElement::StyleElement()
+StyleElement::StyleElement(Document* document, bool createdByParser)
+    : m_createdByParser(createdByParser)
+    , m_loading(false)
+    , m_startLineNumber(0)
 {
+    if (createdByParser && document && document->scriptableDocumentParser())
+        m_startLineNumber = document->scriptableDocumentParser()->lineNumber();
 }
 
 StyleSheet* StyleElement::sheet(Element* e)
@@ -40,13 +46,23 @@ StyleSheet* StyleElement::sheet(Element* e)
     return m_sheet.get();
 }
 
-void StyleElement::insertedIntoDocument(Document*, Element* element)
+void StyleElement::insertedIntoDocument(Document* document, Element* element)
 {
-    process(element, 0);
+    ASSERT(document);
+    ASSERT(element);
+    document->addStyleSheetCandidateNode(element, m_createdByParser);
+    if (m_createdByParser)
+        return;
+
+    process(element);
 }
 
-void StyleElement::removedFromDocument(Document* document)
+void StyleElement::removedFromDocument(Document* document, Element* element)
 {
+    ASSERT(document);
+    ASSERT(element);
+    document->removeStyleSheetCandidateNode(element);
+
     // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
     if (!document->renderer())
         return;
@@ -56,7 +72,24 @@ void StyleElement::removedFromDocument(Document* document)
         document->updateStyleSelector();
 }
 
-void StyleElement::process(Element* e, int startLineNumber)
+void StyleElement::childrenChanged(Element* element)
+{
+    ASSERT(element);
+    if (m_createdByParser)
+        return;
+
+    process(element);
+}
+
+void StyleElement::finishParsingChildren(Element* element)
+{
+    ASSERT(element);
+    process(element);
+    sheet(element);
+    m_createdByParser = false;
+}
+
+void StyleElement::process(Element* e)
 {
     if (!e || !e->inDocument())
         return;
@@ -82,14 +115,15 @@ void StyleElement::process(Element* e, int startLineNumber)
     }
     ASSERT(p == text + resultLength);
 
-    createSheet(e, startLineNumber, sheetText);
+    createSheet(e, m_startLineNumber, sheetText);
 }
 
 void StyleElement::createSheet(Element* e, int startLineNumber, const String& text)
 {
+    ASSERT(e);
     Document* document = e->document();
     if (m_sheet) {
-        if (static_cast<CSSStyleSheet*>(m_sheet.get())->isLoading())
+        if (m_sheet->isLoading())
             document->removePendingSheet();
         m_sheet = 0;
     }
@@ -102,12 +136,12 @@ void StyleElement::createSheet(Element* e, int startLineNumber, const String& te
         MediaQueryEvaluator printEval("print", true);
         if (screenEval.eval(mediaList.get()) || printEval.eval(mediaList.get())) {
             document->addPendingSheet();
-            setLoading(true);
+            m_loading = true;
             m_sheet = CSSStyleSheet::create(e, String(), KURL(), document->inputEncoding());
             m_sheet->parseStringAtLine(text, !document->inCompatMode(), startLineNumber);
             m_sheet->setMedia(mediaList.get());
             m_sheet->setTitle(e->title());
-            setLoading(false);
+            m_loading = false;
         }
     }
 
@@ -115,4 +149,21 @@ void StyleElement::createSheet(Element* e, int startLineNumber, const String& te
         m_sheet->checkLoaded();
 }
 
+bool StyleElement::isLoading() const
+{
+    if (m_loading)
+        return true;
+    return m_sheet ? m_sheet->isLoading() : false;
+}
+
+bool StyleElement::sheetLoaded(Document* document)
+{
+    ASSERT(document);
+    if (isLoading())
+        return false;
+
+    document->removePendingSheet();
+    return true;
+}
+
 }
diff --git a/WebCore/dom/StyleElement.h b/WebCore/dom/StyleElement.h
index 4ec10c4..00e45ed 100644
--- a/WebCore/dom/StyleElement.h
+++ b/WebCore/dom/StyleElement.h
@@ -17,6 +17,7 @@
  * Boston, MA 02110-1301, USA.
  *
  */
+
 #ifndef StyleElement_h
 #define StyleElement_h
 
@@ -29,27 +30,34 @@ class Element;
 
 class StyleElement {
 public:
-    StyleElement();
+    StyleElement(Document*, bool createdByParser);
     virtual ~StyleElement() {}
 
 protected:
-    StyleSheet* sheet(Element*);
-
-    virtual void setLoading(bool) {}
-
     virtual const AtomicString& type() const = 0;
     virtual const AtomicString& media() const = 0;
 
-    void insertedIntoDocument(Document*, Element*);
-    void removedFromDocument(Document*);
-    void process(Element*, int startLineNumber);
+    StyleSheet* sheet(Element*);
 
-    void createSheet(Element* e, int startLineNumber, const String& text = String());
+    bool isLoading() const;
+    bool sheetLoaded(Document*);
+
+    void insertedIntoDocument(Document*, Element*);
+    void removedFromDocument(Document*, Element*);
+    void childrenChanged(Element*);
+    void finishParsingChildren(Element*);
 
-protected:
     RefPtr<CSSStyleSheet> m_sheet;
+
+private:
+    void createSheet(Element*, int startLineNumber, const String& text = String());
+    void process(Element*);
+
+    bool m_createdByParser;
+    bool m_loading;
+    int m_startLineNumber;
 };
 
-} //namespace
+}
 
 #endif
diff --git a/WebCore/html/HTMLStyleElement.cpp b/WebCore/html/HTMLStyleElement.cpp
index 4fa08ad..1066c75 100644
--- a/WebCore/html/HTMLStyleElement.cpp
+++ b/WebCore/html/HTMLStyleElement.cpp
@@ -36,13 +36,9 @@ using namespace HTMLNames;
 
 inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document* document, bool createdByParser)
     : HTMLElement(tagName, document)
-    , m_loading(false)
-    , m_createdByParser(createdByParser)
-    , m_startLineNumber(0)
+    , StyleElement(document, createdByParser)
 {
     ASSERT(hasTagName(styleTag));
-    if (createdByParser && document && document->scriptableDocumentParser())
-        m_startLineNumber = document->scriptableDocumentParser()->lineNumber();
 }
 
 PassRefPtr<HTMLStyleElement> HTMLStyleElement::create(const QualifiedName& tagName, Document* document, bool createdByParser)
@@ -62,32 +58,25 @@ void HTMLStyleElement::parseMappedAttribute(Attribute* attr)
 
 void HTMLStyleElement::finishParsingChildren()
 {
-    StyleElement::process(this, m_startLineNumber);
-    StyleElement::sheet(this);
-    m_createdByParser = false;
+    StyleElement::finishParsingChildren(this);
     HTMLElement::finishParsingChildren();
 }
 
 void HTMLStyleElement::insertedIntoDocument()
 {
     HTMLElement::insertedIntoDocument();
-
-    document()->addStyleSheetCandidateNode(this, m_createdByParser);
-    if (!m_createdByParser)
-        StyleElement::insertedIntoDocument(document(), this);
+    StyleElement::insertedIntoDocument(document(), this);
 }
 
 void HTMLStyleElement::removedFromDocument()
 {
     HTMLElement::removedFromDocument();
-    document()->removeStyleSheetCandidateNode(this);
-    StyleElement::removedFromDocument(document());
+    StyleElement::removedFromDocument(document(), this);
 }
 
 void HTMLStyleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
 {
-    if (!changedByParser)
-        StyleElement::process(this, 0);
+    StyleElement::childrenChanged(this);
     HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
 }
 
@@ -96,24 +85,6 @@ StyleSheet* HTMLStyleElement::sheet()
     return StyleElement::sheet(this);
 }
 
-bool HTMLStyleElement::isLoading() const
-{
-    if (m_loading)
-        return true;
-    if (!m_sheet)
-        return false;
-    return static_cast<CSSStyleSheet *>(m_sheet.get())->isLoading();
-}
-
-bool HTMLStyleElement::sheetLoaded()
-{
-    if (!isLoading()) {
-        document()->removePendingSheet();
-        return true;
-    }
-    return false;
-}
-
 const AtomicString& HTMLStyleElement::media() const
 {
     return getAttribute(mediaAttr);
diff --git a/WebCore/html/HTMLStyleElement.h b/WebCore/html/HTMLStyleElement.h
index 10f5b10..07b5bd9 100644
--- a/WebCore/html/HTMLStyleElement.h
+++ b/WebCore/html/HTMLStyleElement.h
@@ -53,19 +53,13 @@ private:
 
     virtual void finishParsingChildren();
 
-    virtual bool isLoading() const;
-    virtual bool sheetLoaded();
-
-    virtual void setLoading(bool loading) { m_loading = loading; }
+    virtual bool isLoading() const { return StyleElement::isLoading(); }
+    virtual bool sheetLoaded() { return StyleElement::sheetLoaded(document()); }
 
     virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
 
     virtual const AtomicString& media() const;
     virtual const AtomicString& type() const;
-
-    bool m_loading;
-    bool m_createdByParser;
-    int m_startLineNumber;
 };
 
 } //namespace
diff --git a/WebCore/svg/SVGStyleElement.cpp b/WebCore/svg/SVGStyleElement.cpp
index 48fbe69..6050e84 100644
--- a/WebCore/svg/SVGStyleElement.cpp
+++ b/WebCore/svg/SVGStyleElement.cpp
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox at kde.org>
+    Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann at kde.org>
                   2004, 2005, 2006, 2007 Rob Buis <buis at kde.org>
     Copyright (C) 2006 Apple Computer, Inc.
     Copyright (C) 2009 Cameron McCormack <cam at mcc.id.au>
@@ -34,12 +34,10 @@
 
 namespace WebCore {
 
-using namespace SVGNames;
-
-SVGStyleElement::SVGStyleElement(const QualifiedName& tagName, Document* doc, bool createdByParser)
-     : SVGElement(tagName, doc)
-     , SVGLangSpace()
-     , m_createdByParser(createdByParser)
+SVGStyleElement::SVGStyleElement(const QualifiedName& tagName, Document* document, bool createdByParser)
+    : SVGElement(tagName, document)
+    , SVGLangSpace()
+    , StyleElement(document, createdByParser)
 {
 }
 
@@ -90,31 +88,26 @@ void SVGStyleElement::parseMappedAttribute(Attribute* attr)
 
 void SVGStyleElement::finishParsingChildren()
 {
-    StyleElement::sheet(this);
-    m_createdByParser = false;
+    StyleElement::finishParsingChildren(this);
     SVGElement::finishParsingChildren();
 }
 
 void SVGStyleElement::insertedIntoDocument()
 {
     SVGElement::insertedIntoDocument();
-    document()->addStyleSheetCandidateNode(this, m_createdByParser);
-    if (!m_createdByParser)
-        StyleElement::insertedIntoDocument(document(), this);
+    StyleElement::insertedIntoDocument(document(), this);
 }
 
 void SVGStyleElement::removedFromDocument()
 {
     SVGElement::removedFromDocument();
-    if (document()->renderer())
-        document()->removeStyleSheetCandidateNode(this);
-    StyleElement::removedFromDocument(document());
+    StyleElement::removedFromDocument(document(), this);
 }
 
 void SVGStyleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
 {
+    StyleElement::childrenChanged(this);
     SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
-    StyleElement::process(this, 0);
 }
 
 StyleSheet* SVGStyleElement::sheet()
@@ -122,13 +115,6 @@ StyleSheet* SVGStyleElement::sheet()
     return StyleElement::sheet(this);
 }
 
-bool SVGStyleElement::sheetLoaded()
-{
-    document()->removePendingSheet();
-    return true;
-}
-
 }
 
-// vim:ts=4:noet
 #endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGStyleElement.h b/WebCore/svg/SVGStyleElement.h
index ae7ed57..fe11f9c 100644
--- a/WebCore/svg/SVGStyleElement.h
+++ b/WebCore/svg/SVGStyleElement.h
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox at kde.org>
+    Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann at kde.org>
                   2004, 2005, 2006, 2007 Rob Buis <buis at kde.org>
 
     This library is free software; you can redistribute it and/or
@@ -20,48 +20,43 @@
 
 #ifndef SVGStyleElement_h
 #define SVGStyleElement_h
-#if ENABLE(SVG)
 
-#include <SVGElement.h>
+#if ENABLE(SVG)
+#include "SVGElement.h"
 #include "SVGLangSpace.h"
 #include "StyleElement.h"
 
 namespace WebCore {
 
-    class SVGStyleElement : public SVGElement,
-                            public SVGLangSpace,
-                            public StyleElement {
-    public:
-        SVGStyleElement(const QualifiedName&, Document*, bool createdByParser);
+class SVGStyleElement : public SVGElement
+                      , public SVGLangSpace
+                      , public StyleElement {
+public:
+    SVGStyleElement(const QualifiedName&, Document*, bool createdByParser);
 
-        // Derived from: 'Element'
-        virtual void parseMappedAttribute(Attribute*);
-        virtual void insertedIntoDocument();
-        virtual void removedFromDocument();
-        virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+    virtual void parseMappedAttribute(Attribute*);
+    virtual void insertedIntoDocument();
+    virtual void removedFromDocument();
+    virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
 
-        virtual void finishParsingChildren();
+    virtual void finishParsingChildren();
 
-        virtual bool sheetLoaded();
+    virtual bool isLoading() const { return StyleElement::isLoading(); }
+    virtual bool sheetLoaded() { return StyleElement::sheetLoaded(document()); }
 
-        virtual const AtomicString& type() const;
-        void setType(const AtomicString&, ExceptionCode&);
+    virtual const AtomicString& type() const;
+    void setType(const AtomicString&, ExceptionCode&);
 
-        virtual const AtomicString& media() const;
-        void setMedia(const AtomicString&, ExceptionCode&);
+    virtual const AtomicString& media() const;
+    void setMedia(const AtomicString&, ExceptionCode&);
 
-        virtual String title() const;
-        void setTitle(const AtomicString&, ExceptionCode&);
+    virtual String title() const;
+    void setTitle(const AtomicString&, ExceptionCode&);
 
-        StyleSheet* sheet();
-        
-    protected:
-        bool m_createdByParser;
-    };
+    StyleSheet* sheet();
+};
 
 } // namespace WebCore
 
 #endif // ENABLE(SVG)
 #endif // SVGStyleElement_h
-
-// vim:ts=4:noet

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list