Title: [132787] trunk/Source/WebCore
Revision
132787
Author
[email protected]
Date
2012-10-29 05:37:57 -0700 (Mon, 29 Oct 2012)

Log Message

Move seamless stylesheet collecting to DocumentStyleSheetCollection
https://bugs.webkit.org/show_bug.cgi?id=100655

Reviewed by Andreas Kling.

Move the code from StyleResolver to DocumentStyleSheetCollection. StyleResolver should focus on resolving style.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::StyleResolver):
        
    Use standard create() pattern.

(WebCore):
* css/StyleResolver.h:
(StyleResolver):
* dom/Document.cpp:
(WebCore::Document::Document):
* dom/DocumentStyleSheetCollection.cpp:
(WebCore::collectActiveCSSStyleSheetsFromSeamlessParents):
        
    Since parent activeAuthorStyleSheets() contains all seamlessly inherited sheets too, this does not need to
    iterate to ancestors anymore.

(WebCore):
(WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets):
* dom/DocumentStyleSheetCollection.h:
(WebCore::DocumentStyleSheetCollection::create):
(DocumentStyleSheetCollection):
(WebCore::DocumentStyleSheetCollection::styleSheetsForStyleSheetList):
(WebCore::DocumentStyleSheetCollection::activeAuthorStyleSheets):
        
    activeAuthorStyleSheets() now includes the stylesheets inherited from the seamless parent too.

(WebCore::DocumentStyleSheetCollection::needsUpdateActiveStylesheetsOnStyleRecalc):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132786 => 132787)


--- trunk/Source/WebCore/ChangeLog	2012-10-29 11:44:31 UTC (rev 132786)
+++ trunk/Source/WebCore/ChangeLog	2012-10-29 12:37:57 UTC (rev 132787)
@@ -1,3 +1,40 @@
+2012-10-29  Antti Koivisto  <[email protected]>
+
+        Move seamless stylesheet collecting to DocumentStyleSheetCollection
+        https://bugs.webkit.org/show_bug.cgi?id=100655
+
+        Reviewed by Andreas Kling.
+
+        Move the code from StyleResolver to DocumentStyleSheetCollection. StyleResolver should focus on resolving style.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::StyleResolver):
+        
+            Use standard create() pattern.
+
+        (WebCore):
+        * css/StyleResolver.h:
+        (StyleResolver):
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        * dom/DocumentStyleSheetCollection.cpp:
+        (WebCore::collectActiveCSSStyleSheetsFromSeamlessParents):
+        
+            Since parent activeAuthorStyleSheets() contains all seamlessly inherited sheets too, this does not need to
+            iterate to ancestors anymore.
+
+        (WebCore):
+        (WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets):
+        * dom/DocumentStyleSheetCollection.h:
+        (WebCore::DocumentStyleSheetCollection::create):
+        (DocumentStyleSheetCollection):
+        (WebCore::DocumentStyleSheetCollection::styleSheetsForStyleSheetList):
+        (WebCore::DocumentStyleSheetCollection::activeAuthorStyleSheets):
+        
+            activeAuthorStyleSheets() now includes the stylesheets inherited from the seamless parent too.
+
+        (WebCore::DocumentStyleSheetCollection::needsUpdateActiveStylesheetsOnStyleRecalc):
+
 2012-10-29  Andreas Kling  <[email protected]>
 
         Don't expose implementation details of StylePropertySet storage.

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (132786 => 132787)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-10-29 11:44:31 UTC (rev 132786)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-10-29 12:37:57 UTC (rev 132787)
@@ -330,25 +330,9 @@
     }
 #endif
 
-    addStylesheetsFromSeamlessParents();
     appendAuthorStyleSheets(0, styleSheetCollection->activeAuthorStyleSheets());
 }
 
-void StyleResolver::addStylesheetsFromSeamlessParents()
-{
-    // Build a list of stylesheet lists from our ancestors, and walk that
-    // list in reverse order so that the root-most sheets are appended first.
-    Document* childDocument = document();
-    Vector<const Vector<RefPtr<CSSStyleSheet> >* > ancestorSheets;
-    while (HTMLIFrameElement* parentIFrame = childDocument->seamlessParentIFrame()) {
-        Document* parentDocument = parentIFrame->document();
-        ancestorSheets.append(&parentDocument->styleSheetCollection()->activeAuthorStyleSheets());
-        childDocument = parentDocument;
-    }
-    for (int i = ancestorSheets.size() - 1; i >= 0; i--)
-        appendAuthorStyleSheets(0, *ancestorSheets[i]);
-}
-
 void StyleResolver::addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >* userSheets, RuleSet& userStyle)
 {
     if (!userSheets)

Modified: trunk/Source/WebCore/css/StyleResolver.h (132786 => 132787)


--- trunk/Source/WebCore/css/StyleResolver.h	2012-10-29 11:44:31 UTC (rev 132786)
+++ trunk/Source/WebCore/css/StyleResolver.h	2012-10-29 12:37:57 UTC (rev 132787)
@@ -423,7 +423,6 @@
 private:
     static RenderStyle* s_styleNotYetAvailable;
 
-    void addStylesheetsFromSeamlessParents();
     void addAuthorRulesAndCollectUserRulesFromSheets(const Vector<RefPtr<CSSStyleSheet> >*, RuleSet& userStyle);
 
     void cacheBorderAndBackground();

Modified: trunk/Source/WebCore/dom/Document.cpp (132786 => 132787)


--- trunk/Source/WebCore/dom/Document.cpp	2012-10-29 11:44:31 UTC (rev 132786)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-10-29 12:37:57 UTC (rev 132787)
@@ -446,7 +446,7 @@
 #if ENABLE(MUTATION_OBSERVERS)
     , m_mutationObserverTypes(0)
 #endif
-    , m_styleSheetCollection(adoptPtr(new DocumentStyleSheetCollection(this)))
+    , m_styleSheetCollection(DocumentStyleSheetCollection::create(this))
     , m_readyState(Complete)
     , m_styleRecalcTimer(this, &Document::styleRecalcTimerFired)
     , m_pendingStyleRecalcShouldForce(false)

Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp (132786 => 132787)


--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2012-10-29 11:44:31 UTC (rev 132786)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2012-10-29 12:37:57 UTC (rev 132787)
@@ -31,6 +31,7 @@
 #include "CSSStyleSheet.h"
 #include "Document.h"
 #include "Element.h"
+#include "HTMLIFrameElement.h"
 #include "HTMLLinkElement.h"
 #include "HTMLNames.h"
 #include "HTMLStyleElement.h"
@@ -428,6 +429,14 @@
     }
 }
 
+static void collectActiveCSSStyleSheetsFromSeamlessParents(Vector<RefPtr<CSSStyleSheet> >& sheets, Document* document)
+{
+    HTMLIFrameElement* seamlessParentIFrame = document->seamlessParentIFrame();
+    if (!seamlessParentIFrame)
+        return;
+    sheets.append(seamlessParentIFrame->document()->styleSheetCollection()->activeAuthorStyleSheets());
+}
+
 bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag)
 {
     if (m_document->inStyleRecalc()) {
@@ -446,6 +455,7 @@
     collectActiveStyleSheets(activeStyleSheets);
 
     Vector<RefPtr<CSSStyleSheet> > activeCSSStyleSheets;
+    collectActiveCSSStyleSheetsFromSeamlessParents(activeCSSStyleSheets, m_document);
     filterEnabledCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets);
 
     StyleResolverUpdateType styleResolverUpdateType;

Modified: trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h (132786 => 132787)


--- trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h	2012-10-29 11:44:31 UTC (rev 132786)
+++ trunk/Source/WebCore/dom/DocumentStyleSheetCollection.h	2012-10-29 12:37:57 UTC (rev 132787)
@@ -46,12 +46,13 @@
 class DocumentStyleSheetCollection {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    DocumentStyleSheetCollection(Document*);
+    static PassOwnPtr<DocumentStyleSheetCollection> create(Document* document) { return adoptPtr(new DocumentStyleSheetCollection(document)); }
+
     ~DocumentStyleSheetCollection();
 
-    const Vector<RefPtr<StyleSheet> >& styleSheetsForStyleSheetList() { return m_styleSheetsForStyleSheetList; }
+    const Vector<RefPtr<StyleSheet> >& styleSheetsForStyleSheetList() const { return m_styleSheetsForStyleSheetList; }
 
-    const Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets() { return m_activeAuthorStyleSheets; }
+    const Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets() const { return m_activeAuthorStyleSheets; }
 
     CSSStyleSheet* pageUserSheet();
     const Vector<RefPtr<CSSStyleSheet> >* pageGroupUserSheets() const;
@@ -67,7 +68,7 @@
 
     void addUserSheet(PassRefPtr<StyleSheetContents> userSheet);
 
-    bool needsUpdateActiveStylesheetsOnStyleRecalc() { return m_needsUpdateActiveStylesheetsOnStyleRecalc; }
+    bool needsUpdateActiveStylesheetsOnStyleRecalc() const { return m_needsUpdateActiveStylesheetsOnStyleRecalc; }
 
     enum UpdateFlag { FullUpdate, OptimizedUpdate };
     bool updateActiveStyleSheets(UpdateFlag);
@@ -102,6 +103,8 @@
     void reportMemoryUsage(MemoryObjectInfo*) const;
 
 private:
+    DocumentStyleSheetCollection(Document*);
+
     void collectActiveStyleSheets(Vector<RefPtr<StyleSheet> >&);
     enum StyleResolverUpdateType {
         Reconstruct,
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to