Title: [136454] tags/Safari-537.20.1/Source/WebCore

Diff

Modified: tags/Safari-537.20.1/Source/WebCore/ChangeLog (136453 => 136454)


--- tags/Safari-537.20.1/Source/WebCore/ChangeLog	2012-12-04 00:11:16 UTC (rev 136453)
+++ tags/Safari-537.20.1/Source/WebCore/ChangeLog	2012-12-04 00:22:47 UTC (rev 136454)
@@ -1,3 +1,39 @@
+2012-12-03  Lucas Forschler  <[email protected]>
+
+        Merge r136449
+        (Rollout of 135271)
+
+    2012-12-03  Sheriff Bot  <[email protected]>
+
+            Unreviewed, rolling out r135271.
+            http://trac.webkit.org/changeset/135271
+            https://bugs.webkit.org/show_bug.cgi?id=103940
+
+            Some user stylesheet API clients broken (Requested by anttik
+            on #webkit).
+
+            * css/StyleResolver.cpp:
+            (WebCore::StyleResolver::StyleResolver):
+            (WebCore::StyleResolver::collectRulesFromUserStyleSheets):
+            (WebCore::collectCSSOMWrappers):
+            * css/StyleResolver.h:
+            (StyleResolver):
+            * dom/Document.cpp:
+            (WebCore::Document::setCompatibilityMode):
+            * dom/DocumentStyleSheetCollection.cpp:
+            (WebCore::DocumentStyleSheetCollection::~DocumentStyleSheetCollection):
+            (WebCore::DocumentStyleSheetCollection::pageUserSheet):
+            (WebCore::DocumentStyleSheetCollection::clearPageUserSheet):
+            (WebCore::DocumentStyleSheetCollection::updatePageUserSheet):
+            (WebCore::collectActiveCSSStyleSheetsFromSeamlessParents):
+            (WebCore::DocumentStyleSheetCollection::updateActiveStyleSheets):
+            (WebCore::DocumentStyleSheetCollection::reportMemoryUsage):
+            * dom/DocumentStyleSheetCollection.h:
+            (DocumentStyleSheetCollection):
+            (WebCore::DocumentStyleSheetCollection::documentUserStyleSheets):
+            * page/Page.cpp:
+            (WebCore::Page::userStyleSheetLocationChanged):
+
 2012-11-29  Viatcheslav Ostapenko  <[email protected]>
 
         Fix typo in commit 136189

Modified: tags/Safari-537.20.1/Source/WebCore/css/StyleResolver.cpp (136453 => 136454)


--- tags/Safari-537.20.1/Source/WebCore/css/StyleResolver.cpp	2012-12-04 00:11:16 UTC (rev 136453)
+++ tags/Safari-537.20.1/Source/WebCore/css/StyleResolver.cpp	2012-12-04 00:22:47 UTC (rev 136454)
@@ -297,8 +297,17 @@
             loadFullDefaultStyle();
     }
 
+    // construct document root element default style. this is needed
+    // to evaluate media queries that contain relative constraints, like "screen and (max-width: 10em)"
+    // This is here instead of constructor, because when constructor is run,
+    // document doesn't have documentElement
+    // NOTE: this assumes that element that gets passed to styleForElement -call
+    // is always from the document that owns the style selector
     FrameView* view = document->view();
-    m_medium = adoptPtr(new MediaQueryEvaluator(view ? view->mediaType() : "all"));
+    if (view)
+        m_medium = adoptPtr(new MediaQueryEvaluator(view->mediaType()));
+    else
+        m_medium = adoptPtr(new MediaQueryEvaluator("all"));
 
     if (root)
         m_rootDefaultStyle = styleForElement(root, 0, DisallowStyleSharing, MatchOnlyUserAgentRules);
@@ -308,6 +317,15 @@
 
     resetAuthorStyle();
 
+    DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCollection();
+    OwnPtr<RuleSet> tempUserStyle = RuleSet::create();
+    if (CSSStyleSheet* pageUserSheet = styleSheetCollection->pageUserSheet())
+        tempUserStyle->addRulesFromSheet(pageUserSheet->contents(), *m_medium, this);
+    collectRulesFromUserStyleSheets(styleSheetCollection->injectedUserStyleSheets(), *tempUserStyle);
+    collectRulesFromUserStyleSheets(styleSheetCollection->documentUserStyleSheets(), *tempUserStyle);
+    if (tempUserStyle->m_ruleCount > 0 || tempUserStyle->m_pageRules.size() > 0)
+        m_userStyle = tempUserStyle.release();
+
 #if ENABLE(SVG_FONTS)
     if (document->svgExtensions()) {
         const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document->svgExtensions()->svgFontFaceElements();
@@ -317,20 +335,15 @@
     }
 #endif
 
-    DocumentStyleSheetCollection* styleSheetCollection = document->styleSheetCollection();
-    collectRulesFromUserStyleSheets(styleSheetCollection->activeUserStyleSheets());
     appendAuthorStyleSheets(0, styleSheetCollection->activeAuthorStyleSheets());
 }
 
-void StyleResolver::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& userSheets)
+void StyleResolver::collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& userSheets, RuleSet& userStyle)
 {
-    OwnPtr<RuleSet> userStyleRuleSet = RuleSet::create();
     for (unsigned i = 0; i < userSheets.size(); ++i) {
         ASSERT(userSheets[i]->contents()->isUserStyleSheet());
-        userStyleRuleSet->addRulesFromSheet(userSheets[i]->contents(), *m_medium, this);
+        userStyle.addRulesFromSheet(userSheets[i]->contents(), *m_medium, this);
     }
-    if (userStyleRuleSet->m_ruleCount > 0 || userStyleRuleSet->m_pageRules.size() > 0)
-        m_userStyle = userStyleRuleSet.release();
 }
 
 static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules)
@@ -2564,7 +2577,9 @@
 static void collectCSSOMWrappers(HashMap<StyleRule*, RefPtr<CSSStyleRule> >& wrapperMap, DocumentStyleSheetCollection* styleSheetCollection)
 {
     collectCSSOMWrappers(wrapperMap, styleSheetCollection->activeAuthorStyleSheets());
-    collectCSSOMWrappers(wrapperMap, styleSheetCollection->activeUserStyleSheets());
+    collectCSSOMWrappers(wrapperMap, styleSheetCollection->pageUserSheet());
+    collectCSSOMWrappers(wrapperMap, styleSheetCollection->injectedUserStyleSheets());
+    collectCSSOMWrappers(wrapperMap, styleSheetCollection->documentUserStyleSheets());
 }
 
 CSSStyleRule* StyleResolver::ensureFullCSSOMWrapperForInspector(StyleRule* rule)

Modified: tags/Safari-537.20.1/Source/WebCore/css/StyleResolver.h (136453 => 136454)


--- tags/Safari-537.20.1/Source/WebCore/css/StyleResolver.h	2012-12-04 00:11:16 UTC (rev 136453)
+++ tags/Safari-537.20.1/Source/WebCore/css/StyleResolver.h	2012-12-04 00:22:47 UTC (rev 136454)
@@ -426,7 +426,7 @@
 private:
     static RenderStyle* s_styleNotYetAvailable;
 
-    void collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&);
+    void collectRulesFromUserStyleSheets(const Vector<RefPtr<CSSStyleSheet> >&, RuleSet& userStyle);
 
     void cacheBorderAndBackground();
 

Modified: tags/Safari-537.20.1/Source/WebCore/dom/Document.cpp (136453 => 136454)


--- tags/Safari-537.20.1/Source/WebCore/dom/Document.cpp	2012-12-04 00:11:16 UTC (rev 136453)
+++ tags/Safari-537.20.1/Source/WebCore/dom/Document.cpp	2012-12-04 00:22:47 UTC (rev 136454)
@@ -785,7 +785,7 @@
     selectorQueryCache()->invalidate();
     if (inQuirksMode() != wasInQuirksMode) {
         // All user stylesheets have to reparse using the different mode.
-        m_styleSheetCollection->clearPageUserStyleSheet();
+        m_styleSheetCollection->clearPageUserSheet();
         m_styleSheetCollection->invalidateInjectedStyleSheetCache();
     }
 }

Modified: tags/Safari-537.20.1/Source/WebCore/dom/DocumentStyleSheetCollection.cpp (136453 => 136454)


--- tags/Safari-537.20.1/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2012-12-04 00:11:16 UTC (rev 136453)
+++ tags/Safari-537.20.1/Source/WebCore/dom/DocumentStyleSheetCollection.cpp	2012-12-04 00:22:47 UTC (rev 136454)
@@ -73,8 +73,8 @@
 
 DocumentStyleSheetCollection::~DocumentStyleSheetCollection()
 {
-    if (m_pageUserStyleSheet)
-        m_pageUserStyleSheet->clearOwnerNode();
+    if (m_pageUserSheet)
+        m_pageUserSheet->clearOwnerNode();
     for (unsigned i = 0; i < m_injectedUserStyleSheets.size(); ++i)
         m_injectedUserStyleSheets[i]->clearOwnerNode();
     for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i)
@@ -100,10 +100,10 @@
     m_usesBeforeAfterRules = styleResolver->usesBeforeAfterRules();
 }
 
-CSSStyleSheet* DocumentStyleSheetCollection::pageUserStyleSheet()
+CSSStyleSheet* DocumentStyleSheetCollection::pageUserSheet()
 {
-    if (m_pageUserStyleSheet)
-        return m_pageUserStyleSheet.get();
+    if (m_pageUserSheet)
+        return m_pageUserSheet.get();
     
     Page* owningPage = m_document->page();
     if (!owningPage)
@@ -114,24 +114,24 @@
         return 0;
     
     // Parse the sheet and cache it.
-    m_pageUserStyleSheet = CSSStyleSheet::createInline(m_document, m_document->settings()->userStyleSheetLocation());
-    m_pageUserStyleSheet->contents()->setIsUserStyleSheet(true);
-    m_pageUserStyleSheet->contents()->parseString(userSheetText);
-    return m_pageUserStyleSheet.get();
+    m_pageUserSheet = CSSStyleSheet::createInline(m_document, m_document->settings()->userStyleSheetLocation());
+    m_pageUserSheet->contents()->setIsUserStyleSheet(true);
+    m_pageUserSheet->contents()->parseString(userSheetText);
+    return m_pageUserSheet.get();
 }
 
-void DocumentStyleSheetCollection::clearPageUserStyleSheet()
+void DocumentStyleSheetCollection::clearPageUserSheet()
 {
-    if (!m_pageUserStyleSheet)
-        return;
-    m_pageUserStyleSheet = 0;
-    m_document->styleResolverChanged(DeferRecalcStyle);
+    if (m_pageUserSheet) {
+        m_pageUserSheet = 0;
+        m_document->styleResolverChanged(DeferRecalcStyle);
+    }
 }
 
-void DocumentStyleSheetCollection::updatePageUserStyleSheet()
+void DocumentStyleSheetCollection::updatePageUserSheet()
 {
-    clearPageUserStyleSheet();
-    if (pageUserStyleSheet())
+    clearPageUserSheet();
+    if (pageUserSheet())
         m_document->styleResolverChanged(RecalcStyleImmediately);
 }
 
@@ -429,7 +429,7 @@
     }
 }
 
-static void collectActiveStyleSheetsFromSeamlessParents(Vector<RefPtr<CSSStyleSheet> >& sheets, Document* document)
+static void collectActiveCSSStyleSheetsFromSeamlessParents(Vector<RefPtr<CSSStyleSheet> >& sheets, Document* document)
 {
     HTMLIFrameElement* seamlessParentIFrame = document->seamlessParentIFrame();
     if (!seamlessParentIFrame)
@@ -437,25 +437,6 @@
     sheets.append(seamlessParentIFrame->document()->styleSheetCollection()->activeAuthorStyleSheets());
 }
 
-void DocumentStyleSheetCollection::updateStyleResolver(StyleResolverUpdateType updateType, const Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets)
-{
-    if (updateType == Reconstruct) {
-        m_document->clearStyleResolver();
-        return;
-    }
-    StyleResolver* styleResolver = m_document->styleResolver();
-    unsigned firstNewIndex;
-    if (updateType == Reset) {
-        styleResolver->resetAuthorStyle();
-        firstNewIndex = 0;
-    } else {
-        ASSERT(updateType == Additive);
-        firstNewIndex = m_activeAuthorStyleSheets.size();
-    }
-    styleResolver->appendAuthorStyleSheets(firstNewIndex, activeAuthorStyleSheets);
-    resetCSSFeatureFlags();
-}
-
 bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag)
 {
     if (m_document->inStyleRecalc()) {
@@ -470,32 +451,33 @@
     if (!m_document->renderer() || !m_document->attached())
         return false;
 
-    Vector<RefPtr<StyleSheet> > documentAuthorStyleSheets;
-    collectActiveStyleSheets(documentAuthorStyleSheets);
+    Vector<RefPtr<StyleSheet> > activeStyleSheets;
+    collectActiveStyleSheets(activeStyleSheets);
 
-    Vector<RefPtr<CSSStyleSheet> > activeAuthorStyleSheets;
-    activeAuthorStyleSheets.append(injectedAuthorStyleSheets());
-    collectActiveStyleSheetsFromSeamlessParents(activeAuthorStyleSheets, m_document);
-    filterEnabledCSSStyleSheets(activeAuthorStyleSheets, documentAuthorStyleSheets);
+    Vector<RefPtr<CSSStyleSheet> > activeCSSStyleSheets;
+    activeCSSStyleSheets.append(injectedAuthorStyleSheets());
+    collectActiveCSSStyleSheetsFromSeamlessParents(activeCSSStyleSheets, m_document);
+    filterEnabledCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets);
 
-    Vector<RefPtr<CSSStyleSheet> > activeUserStyleSheets;
-    if (CSSStyleSheet* sheet = pageUserStyleSheet())
-        activeUserStyleSheets.append(sheet);
-    activeUserStyleSheets.append(injectedUserStyleSheets());
-    activeUserStyleSheets.append(documentUserStyleSheets());
-
-    if (activeUserStyleSheets != m_activeUserStyleSheets)
-        updateFlag = FullUpdate;
-
     StyleResolverUpdateType styleResolverUpdateType;
     bool requiresFullStyleRecalc;
-    analyzeStyleSheetChange(updateFlag, activeAuthorStyleSheets, styleResolverUpdateType, requiresFullStyleRecalc);
+    analyzeStyleSheetChange(updateFlag, activeCSSStyleSheets, styleResolverUpdateType, requiresFullStyleRecalc);
 
-    updateStyleResolver(styleResolverUpdateType, activeAuthorStyleSheets);
-    
-    m_activeAuthorStyleSheets.swap(activeAuthorStyleSheets);
-    m_activeUserStyleSheets.swap(activeUserStyleSheets);
-    m_styleSheetsForStyleSheetList.swap(documentAuthorStyleSheets);
+    if (styleResolverUpdateType == Reconstruct)
+        m_document->clearStyleResolver();
+    else {
+        StyleResolver* styleResolver = m_document->styleResolver();
+        if (styleResolverUpdateType == Reset) {
+            styleResolver->resetAuthorStyle();
+            styleResolver->appendAuthorStyleSheets(0, activeCSSStyleSheets);
+        } else {
+            ASSERT(styleResolverUpdateType == Additive);
+            styleResolver->appendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), activeCSSStyleSheets);
+        }
+        resetCSSFeatureFlags();
+    }
+    m_activeAuthorStyleSheets.swap(activeCSSStyleSheets);
+    m_styleSheetsForStyleSheetList.swap(activeStyleSheets);
 
     m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets);
     m_needsUpdateActiveStylesheetsOnStyleRecalc = false;
@@ -508,12 +490,11 @@
 void DocumentStyleSheetCollection::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
-    info.addMember(m_pageUserStyleSheet);
+    info.addMember(m_pageUserSheet);
     info.addMember(m_injectedUserStyleSheets);
     info.addMember(m_injectedAuthorStyleSheets);
     info.addMember(m_userStyleSheets);
     info.addMember(m_activeAuthorStyleSheets);
-    info.addMember(m_activeUserStyleSheets);
     info.addMember(m_styleSheetsForStyleSheetList);
     info.addMember(m_styleSheetCandidateNodes);
     info.addMember(m_preferredStylesheetSetName);

Modified: tags/Safari-537.20.1/Source/WebCore/dom/DocumentStyleSheetCollection.h (136453 => 136454)


--- tags/Safari-537.20.1/Source/WebCore/dom/DocumentStyleSheetCollection.h	2012-12-04 00:11:16 UTC (rev 136453)
+++ tags/Safari-537.20.1/Source/WebCore/dom/DocumentStyleSheetCollection.h	2012-12-04 00:22:47 UTC (rev 136454)
@@ -53,13 +53,17 @@
     const Vector<RefPtr<StyleSheet> >& styleSheetsForStyleSheetList() const { return m_styleSheetsForStyleSheetList; }
 
     const Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets() const { return m_activeAuthorStyleSheets; }
-    const Vector<RefPtr<CSSStyleSheet> >& activeUserStyleSheets() const { return m_activeUserStyleSheets; }
 
+    CSSStyleSheet* pageUserSheet();
+    const Vector<RefPtr<CSSStyleSheet> >& documentUserStyleSheets() const { return m_userStyleSheets; }
+    const Vector<RefPtr<CSSStyleSheet> >& injectedUserStyleSheets() const;
+    const Vector<RefPtr<CSSStyleSheet> >& injectedAuthorStyleSheets() const;
+
     void addStyleSheetCandidateNode(Node*, bool createdByParser);
     void removeStyleSheetCandidateNode(Node*);
 
-    void clearPageUserStyleSheet();
-    void updatePageUserStyleSheet();
+    void clearPageUserSheet();
+    void updatePageUserSheet();
     void invalidateInjectedStyleSheetCache();
     void updateInjectedStyleSheetCache() const;
 
@@ -109,18 +113,11 @@
         Additive
     };
     void analyzeStyleSheetChange(UpdateFlag, const Vector<RefPtr<CSSStyleSheet> >& newStylesheets, StyleResolverUpdateType&, bool& requiresFullStyleRecalc);
-    void updateStyleResolver(StyleResolverUpdateType, const Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets);
 
-    CSSStyleSheet* pageUserStyleSheet();
-    const Vector<RefPtr<CSSStyleSheet> >& documentUserStyleSheets() const { return m_userStyleSheets; }
-    const Vector<RefPtr<CSSStyleSheet> >& injectedUserStyleSheets() const;
-    const Vector<RefPtr<CSSStyleSheet> >& injectedAuthorStyleSheets() const;
-
     Document* m_document;
 
     Vector<RefPtr<StyleSheet> > m_styleSheetsForStyleSheetList;
     Vector<RefPtr<CSSStyleSheet> > m_activeAuthorStyleSheets;
-    Vector<RefPtr<CSSStyleSheet> > m_activeUserStyleSheets;
 
     // Track the number of currently loading top-level stylesheets needed for rendering.
     // Sheets loaded using the @import directive are not included in this count.
@@ -128,7 +125,7 @@
     // elements and when it is safe to execute scripts.
     int m_pendingStylesheets;
 
-    RefPtr<CSSStyleSheet> m_pageUserStyleSheet;
+    RefPtr<CSSStyleSheet> m_pageUserSheet;
 
     mutable Vector<RefPtr<CSSStyleSheet> > m_injectedUserStyleSheets;
     mutable Vector<RefPtr<CSSStyleSheet> > m_injectedAuthorStyleSheets;

Modified: tags/Safari-537.20.1/Source/WebCore/page/Page.cpp (136453 => 136454)


--- tags/Safari-537.20.1/Source/WebCore/page/Page.cpp	2012-12-04 00:11:16 UTC (rev 136453)
+++ tags/Safari-537.20.1/Source/WebCore/page/Page.cpp	2012-12-04 00:22:47 UTC (rev 136454)
@@ -855,7 +855,7 @@
 
     for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
         if (frame->document())
-            frame->document()->styleSheetCollection()->updatePageUserStyleSheet();
+            frame->document()->styleSheetCollection()->updatePageUserSheet();
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to