Chromium Code Reviews| Index: Source/core/dom/DocumentStyleSheetCollection.cpp |
| diff --git a/Source/core/dom/DocumentStyleSheetCollection.cpp b/Source/core/dom/DocumentStyleSheetCollection.cpp |
| index d5f9eb9658ace53b0aa2e2ee6266274a856bdbe8..c43fbfd940f70f9236bcaf8ce65a555ba571812e 100644 |
| --- a/Source/core/dom/DocumentStyleSheetCollection.cpp |
| +++ b/Source/core/dom/DocumentStyleSheetCollection.cpp |
| @@ -260,7 +260,7 @@ void DocumentStyleSheetCollection::removeStyleSheetCandidateNode(Node* node) |
| m_styleSheetCandidateNodes.remove(node); |
| } |
| -void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleSheet> >& sheets) |
| +void DocumentStyleSheetCollection::collectStyleSheets(Vector<RefPtr<StyleSheet> >& styleSheets, Vector<RefPtr<CSSStyleSheet> >& activeSheets) |
| { |
| if (m_document->settings() && !m_document->settings()->authorAndUserStylesEnabled()) |
| return; |
| @@ -270,11 +270,11 @@ void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleS |
| for (StyleSheetCandidateListHashSet::iterator it = begin; it != end; ++it) { |
| Node* n = *it; |
| StyleSheet* sheet = 0; |
| + CSSStyleSheet* activeSheet = 0; |
| if (n->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) { |
| // Processing instruction (XML documents only). |
| // We don't support linking to embedded CSS stylesheets, see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion. |
| ProcessingInstruction* pi = static_cast<ProcessingInstruction*>(n); |
| - sheet = pi->sheet(); |
| // Don't apply XSL transforms to already transformed documents -- <rdar://problem/4132806> |
| if (pi->isXSL() && !m_document->transformSourceDocument()) { |
| // Don't apply XSL transforms until loading is finished. |
| @@ -282,6 +282,9 @@ void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleS |
| m_document->applyXSLTransform(pi); |
| return; |
| } |
| + sheet = pi->sheet(); |
| + if (sheet && !sheet->disabled() && sheet->isCSSStyleSheet()) |
| + activeSheet = static_cast<CSSStyleSheet*>(sheet); |
| } else if ((n->isHTMLElement() && (n->hasTagName(linkTag) || n->hasTagName(styleTag))) || (n->isSVGElement() && n->hasTagName(SVGNames::styleTag))) { |
| Element* e = toElement(n); |
| AtomicString title = e->getAttribute(titleAttr); |
| @@ -289,10 +292,8 @@ void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleS |
| if (e->hasLocalName(linkTag)) { |
| // <LINK> element |
| HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(n); |
| - if (linkElement->isDisabled()) |
| - continue; |
| enabledViaScript = linkElement->isEnabledViaScript(); |
| - if (linkElement->styleSheetIsLoading()) { |
| + if (!linkElement->isDisabled() && linkElement->styleSheetIsLoading()) { |
|
dglazkov
2013/06/26 15:56:27
This needs to be untangled too, at some point. We
rune
2013/06/28 09:14:37
Yes, according to the specs, disabled state should
|
| // it is loading but we should still decide which style sheet set to use |
| if (!enabledViaScript && !title.isEmpty() && m_preferredStylesheetSetName.isEmpty()) { |
| const AtomicString& rel = e->getAttribute(relAttr); |
| @@ -301,19 +302,21 @@ void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleS |
| m_selectedStylesheetSetName = title; |
| } |
| } |
| + |
| continue; |
| } |
| - if (!linkElement->sheet()) |
| + sheet = linkElement->sheet(); |
| + if (!sheet) |
| title = nullAtom; |
| - } |
| - // Get the current preferred styleset. This is the |
| - // set of sheets that will be enabled. |
| - if (n->isSVGElement() && n->hasTagName(SVGNames::styleTag)) |
| + } else if (n->isSVGElement() && n->hasTagName(SVGNames::styleTag)) { |
| sheet = static_cast<SVGStyleElement*>(n)->sheet(); |
| - else if (e->hasLocalName(linkTag)) |
| - sheet = static_cast<HTMLLinkElement*>(n)->sheet(); |
| - else if (e->hasTagName(HTMLNames::styleTag)) |
| - sheet = toHTMLStyleElement(n)->sheet(); |
| + } else { |
| + sheet = static_cast<HTMLStyleElement*>(n)->sheet(); |
| + } |
| + |
| + if (sheet && !sheet->disabled() && sheet->isCSSStyleSheet()) |
| + activeSheet = static_cast<CSSStyleSheet*>(sheet); |
| + |
| // Check to see if this sheet belongs to a styleset |
| // (thus making it PREFERRED or ALTERNATE rather than |
| // PERSISTENT). |
| @@ -329,14 +332,16 @@ void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleS |
| m_preferredStylesheetSetName = m_selectedStylesheetSetName = title; |
| } |
| if (title != m_preferredStylesheetSetName) |
| - sheet = 0; |
| + activeSheet = 0; |
| } |
| if (rel.contains("alternate") && title.isEmpty()) |
| - sheet = 0; |
| + activeSheet = 0; |
| } |
| if (sheet) |
| - sheets.append(sheet); |
| + styleSheets.append(sheet); |
| + if (activeSheet) |
| + activeSheets.append(activeSheet); |
| } |
| } |
| @@ -408,17 +413,6 @@ static bool styleSheetsUseRemUnits(const Vector<RefPtr<CSSStyleSheet> >& sheets) |
| return false; |
| } |
| -static void filterEnabledCSSStyleSheets(Vector<RefPtr<CSSStyleSheet> >& result, const Vector<RefPtr<StyleSheet> >& sheets) |
| -{ |
| - for (unsigned i = 0; i < sheets.size(); ++i) { |
| - if (!sheets[i]->isCSSStyleSheet()) |
| - continue; |
| - if (sheets[i]->disabled()) |
|
dglazkov
2013/06/26 15:56:27
How did this used to work with <link>?
rune
2013/06/28 09:14:37
It would be caught by the code I removed from coll
|
| - continue; |
| - result.append(static_cast<CSSStyleSheet*>(sheets[i].get())); |
| - } |
| -} |
| - |
| static void collectActiveCSSStyleSheetsFromSeamlessParents(Vector<RefPtr<CSSStyleSheet> >& sheets, Document* document) |
| { |
| HTMLIFrameElement* seamlessParentIFrame = document->seamlessParentIFrame(); |
| @@ -441,14 +435,12 @@ bool DocumentStyleSheetCollection::updateActiveStyleSheets(StyleResolverUpdateMo |
| if (!m_document->renderer() || !m_document->attached()) |
| return false; |
| - Vector<RefPtr<StyleSheet> > activeStyleSheets; |
| - collectActiveStyleSheets(activeStyleSheets); |
| - |
| + Vector<RefPtr<StyleSheet> > cssStyleSheets; |
|
dglazkov
2013/06/26 15:56:27
Does "css" prefix carry any information here? Mayb
rune
2013/06/28 09:14:37
Possibly not. According to the CSSOM spec, StyleSh
|
| Vector<RefPtr<CSSStyleSheet> > activeCSSStyleSheets; |
| activeCSSStyleSheets.append(injectedAuthorStyleSheets()); |
| activeCSSStyleSheets.append(documentAuthorStyleSheets()); |
| collectActiveCSSStyleSheetsFromSeamlessParents(activeCSSStyleSheets, m_document); |
| - filterEnabledCSSStyleSheets(activeCSSStyleSheets, activeStyleSheets); |
| + collectStyleSheets(cssStyleSheets, activeCSSStyleSheets); |
| StyleResolverUpdateType styleResolverUpdateType; |
| bool requiresFullStyleRecalc; |
| @@ -468,8 +460,8 @@ bool DocumentStyleSheetCollection::updateActiveStyleSheets(StyleResolverUpdateMo |
| resetCSSFeatureFlags(); |
| } |
| m_activeAuthorStyleSheets.swap(activeCSSStyleSheets); |
| - InspectorInstrumentation::activeStyleSheetsUpdated(m_document, activeStyleSheets); |
| - m_styleSheetsForStyleSheetList.swap(activeStyleSheets); |
| + InspectorInstrumentation::activeStyleSheetsUpdated(m_document, cssStyleSheets); |
|
dglazkov
2013/06/26 15:56:27
I guess the name of this function should change to
rune
2013/06/28 09:14:37
Yes. So this changes which stylesheets are passed
rune
2013/06/28 09:37:25
Also, changing this method name means changing Ins
|
| + m_styleSheetsForStyleSheetList.swap(cssStyleSheets); |
| m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); |
| m_needsUpdateActiveStylesheetsOnStyleRecalc = false; |