Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: Source/core/dom/DocumentStyleSheetCollection.cpp

Issue 143463011: [import] support document.stylesheets in imported documents. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Landing Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2013 Google Inc. All rights reserved. 9 * Copyright (C) 2013 Google Inc. All rights reserved.
10 * 10 *
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return; 74 return;
75 } 75 }
76 76
77 continue; 77 continue;
78 } 78 }
79 79
80 if (candidate.isImport()) { 80 if (candidate.isImport()) {
81 Document* document = candidate.importedDocument(); 81 Document* document = candidate.importedDocument();
82 if (!document) 82 if (!document)
83 continue; 83 continue;
84 if (collector.hasVisited(document)) 84 document->styleEngine()->updateStyleSheetsInImport(collector);
85 continue;
86 collector.markVisited(document);
87 document->styleEngine()->collectDocumentStyleSheets(collector);
88 continue; 85 continue;
89 } 86 }
90 87
91 if (candidate.isEnabledAndLoading()) { 88 if (candidate.isEnabledAndLoading()) {
92 // it is loading but we should still decide which style sheet set to use 89 // it is loading but we should still decide which style sheet set to use
93 if (candidate.hasPreferrableName(engine->preferredStylesheetSetName( ))) 90 if (candidate.hasPreferrableName(engine->preferredStylesheetSetName( )))
94 engine->selectStylesheetSetName(candidate.title()); 91 engine->selectStylesheetSetName(candidate.title());
95 continue; 92 continue;
96 } 93 }
97 94
98 StyleSheet* sheet = candidate.sheet(); 95 StyleSheet* sheet = candidate.sheet();
99 if (!sheet) 96 if (!sheet)
100 continue; 97 continue;
101 98
102 if (candidate.hasPreferrableName(engine->preferredStylesheetSetName())) 99 if (candidate.hasPreferrableName(engine->preferredStylesheetSetName()))
103 engine->selectStylesheetSetName(candidate.title()); 100 engine->selectStylesheetSetName(candidate.title());
104 if (collector.isCollectingForList(m_treeScope)) 101 collector.appendSheetForList(sheet);
105 collector.appendSheetForList(sheet);
106 if (candidate.canBeActivated(engine->preferredStylesheetSetName())) 102 if (candidate.canBeActivated(engine->preferredStylesheetSetName()))
107 collector.appendActiveStyleSheet(toCSSStyleSheet(sheet)); 103 collector.appendActiveStyleSheet(toCSSStyleSheet(sheet));
108 } 104 }
109 } 105 }
110 106
111 static void collectActiveCSSStyleSheetsFromSeamlessParents(StyleSheetCollectionB ase& collection, Document* document) 107 static void collectActiveCSSStyleSheetsFromSeamlessParents(DocumentStyleSheetCol lector& collector, Document* document)
112 { 108 {
113 HTMLIFrameElement* seamlessParentIFrame = document->seamlessParentIFrame(); 109 HTMLIFrameElement* seamlessParentIFrame = document->seamlessParentIFrame();
114 if (!seamlessParentIFrame) 110 if (!seamlessParentIFrame)
115 return; 111 return;
116 collection.appendActiveStyleSheets(seamlessParentIFrame->document().styleEng ine()->activeAuthorStyleSheets()); 112 collector.appendActiveStyleSheets(seamlessParentIFrame->document().styleEngi ne()->activeAuthorStyleSheets());
117 } 113 }
118 114
119 void DocumentStyleSheetCollection::collectStyleSheets(StyleEngine* engine, Docum entStyleSheetCollector& collector) 115 void DocumentStyleSheetCollection::collectStyleSheets(StyleEngine* engine, Docum entStyleSheetCollector& collector)
120 { 116 {
121 ASSERT(document()->styleEngine() == engine); 117 ASSERT(document()->styleEngine() == engine);
122 collector.appendActiveStyleSheets(engine->injectedAuthorStyleSheets()); 118 collector.appendActiveStyleSheets(engine->injectedAuthorStyleSheets());
123 collector.appendActiveStyleSheets(engine->documentAuthorStyleSheets()); 119 collector.appendActiveStyleSheets(engine->documentAuthorStyleSheets());
124 collectActiveCSSStyleSheetsFromSeamlessParents(collector.collection(), docum ent()); 120 collectActiveCSSStyleSheetsFromSeamlessParents(collector, document());
125 collectStyleSheetsFromCandidates(engine, collector); 121 collectStyleSheetsFromCandidates(engine, collector);
126 } 122 }
127 123
128 bool DocumentStyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine, StyleResolverUpdateMode updateMode) 124 bool DocumentStyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine, StyleResolverUpdateMode updateMode)
129 { 125 {
130 DocumentStyleSheetCollector collector(m_treeScope); 126 StyleSheetCollectionBase collection;
127 ActiveDocumentStyleSheetCollector collector(collection);
131 collectStyleSheets(engine, collector); 128 collectStyleSheets(engine, collector);
132 129
133 StyleSheetChange change; 130 StyleSheetChange change;
134 analyzeStyleSheetChange(updateMode, collector.collection(), change); 131 analyzeStyleSheetChange(updateMode, collection, change);
135 132
136 if (change.styleResolverUpdateType == Reconstruct) { 133 if (change.styleResolverUpdateType == Reconstruct) {
137 engine->clearMasterResolver(); 134 engine->clearMasterResolver();
138 engine->resetFontSelector(); 135 engine->resetFontSelector();
139 } else if (StyleResolver* styleResolver = engine->resolver()) { 136 } else if (StyleResolver* styleResolver = engine->resolver()) {
140 // FIXME: We might have already had styles in child treescope. In this c ase, we cannot use buildScopedStyleTreeInDocumentOrder. 137 // FIXME: We might have already had styles in child treescope. In this c ase, we cannot use buildScopedStyleTreeInDocumentOrder.
141 // Need to change "false" to some valid condition. 138 // Need to change "false" to some valid condition.
142 styleResolver->setBuildScopedStyleTreeInDocumentOrder(false); 139 styleResolver->setBuildScopedStyleTreeInDocumentOrder(false);
143 if (change.styleResolverUpdateType != Additive) { 140 if (change.styleResolverUpdateType != Additive) {
144 ASSERT(change.styleResolverUpdateType == Reset || change.styleResolv erUpdateType == ResetStyleResolverAndFontSelector); 141 ASSERT(change.styleResolverUpdateType == Reset || change.styleResolv erUpdateType == ResetStyleResolverAndFontSelector);
145 resetAllRuleSetsInTreeScope(styleResolver); 142 resetAllRuleSetsInTreeScope(styleResolver);
146 if (change.styleResolverUpdateType == ResetStyleResolverAndFontSelec tor) 143 if (change.styleResolverUpdateType == ResetStyleResolverAndFontSelec tor)
147 engine->resetFontSelector(); 144 engine->resetFontSelector();
148 styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleShe ets); 145 styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleShe ets);
149 styleResolver->lazyAppendAuthorStyleSheets(0, collector.collection() .activeAuthorStyleSheets()); 146 styleResolver->lazyAppendAuthorStyleSheets(0, collection.activeAutho rStyleSheets());
150 } else { 147 } else {
151 styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets .size(), collector.collection().activeAuthorStyleSheets()); 148 styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets .size(), collection.activeAuthorStyleSheets());
152 } 149 }
153 } else if (change.styleResolverUpdateType == ResetStyleResolverAndFontSelect or) { 150 } else if (change.styleResolverUpdateType == ResetStyleResolverAndFontSelect or) {
154 engine->resetFontSelector(); 151 engine->resetFontSelector();
155 } 152 }
156 m_scopingNodesForStyleScoped.didRemoveScopingNodes(); 153 m_scopingNodesForStyleScoped.didRemoveScopingNodes();
157 collector.setCollectionTo(*this); 154
155 collection.swap(*this);
156
158 updateUsesRemUnits(); 157 updateUsesRemUnits();
159 158
160 return change.requiresFullStyleRecalc; 159 return change.requiresFullStyleRecalc;
161 } 160 }
162 161
163 } 162 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/html/imports/import-style-basic-expected.txt ('k') | Source/core/dom/DocumentStyleSheetCollector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698