This source file includes following definitions.
- collectStyleSheetsFromCandidates
- collectStyleSheets
- updateActiveStyleSheets
#include "config.h"
#include "core/dom/DocumentStyleSheetCollection.h"
#include "HTMLNames.h"
#include "RuntimeEnabledFeatures.h"
#include "SVGNames.h"
#include "core/css/CSSStyleSheet.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Document.h"
#include "core/dom/DocumentStyleSheetCollector.h"
#include "core/dom/Element.h"
#include "core/dom/ProcessingInstruction.h"
#include "core/dom/StyleEngine.h"
#include "core/dom/StyleSheetCandidate.h"
#include "core/html/HTMLIFrameElement.h"
#include "core/html/HTMLLinkElement.h"
#include "core/html/HTMLStyleElement.h"
#include "core/frame/Settings.h"
#include "core/svg/SVGStyleElement.h"
namespace WebCore {
using namespace HTMLNames;
DocumentStyleSheetCollection::DocumentStyleSheetCollection(TreeScope& treeScope)
: TreeScopeStyleSheetCollection(treeScope)
{
ASSERT(treeScope.rootNode() == treeScope.rootNode().document());
}
void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(StyleEngine* engine, DocumentStyleSheetCollector& collector)
{
DocumentOrderedList::iterator begin = m_styleSheetCandidateNodes.begin();
DocumentOrderedList::iterator end = m_styleSheetCandidateNodes.end();
for (DocumentOrderedList::iterator it = begin; it != end; ++it) {
Node* n = *it;
StyleSheetCandidate candidate(*n);
if (candidate.isXSL()) {
if (RuntimeEnabledFeatures::xsltEnabled() && !document().transformSourceDocument()) {
ProcessingInstruction* pi = toProcessingInstruction(n);
if (!document().parsing() && !pi->isLoading())
document().applyXSLTransform(pi);
return;
}
continue;
}
if (candidate.isImport()) {
Document* document = candidate.importedDocument();
if (!document)
continue;
if (collector.hasVisited(document))
continue;
collector.willVisit(document);
document->styleEngine()->updateStyleSheetsInImport(collector);
continue;
}
if (candidate.isEnabledAndLoading()) {
if (candidate.hasPreferrableName(engine->preferredStylesheetSetName()))
engine->selectStylesheetSetName(candidate.title());
continue;
}
StyleSheet* sheet = candidate.sheet();
if (!sheet)
continue;
if (candidate.hasPreferrableName(engine->preferredStylesheetSetName()))
engine->selectStylesheetSetName(candidate.title());
collector.appendSheetForList(sheet);
if (candidate.canBeActivated(engine->preferredStylesheetSetName()))
collector.appendActiveStyleSheet(toCSSStyleSheet(sheet));
}
}
void DocumentStyleSheetCollection::collectStyleSheets(StyleEngine* engine, DocumentStyleSheetCollector& collector)
{
ASSERT(document().styleEngine() == engine);
collector.appendActiveStyleSheets(engine->injectedAuthorStyleSheets());
collector.appendActiveStyleSheets(engine->documentAuthorStyleSheets());
collectStyleSheetsFromCandidates(engine, collector);
}
bool DocumentStyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine, StyleResolverUpdateMode updateMode)
{
StyleSheetCollection collection;
ActiveDocumentStyleSheetCollector collector(collection);
collectStyleSheets(engine, collector);
StyleSheetChange change;
analyzeStyleSheetChange(updateMode, collection, change);
if (change.styleResolverUpdateType == Reconstruct) {
engine->clearMasterResolver();
engine->clearFontCache();
} else if (StyleResolver* styleResolver = engine->resolver()) {
styleResolver->setBuildScopedStyleTreeInDocumentOrder(false);
if (change.styleResolverUpdateType != Additive) {
ASSERT(change.styleResolverUpdateType == Reset);
resetAllRuleSetsInTreeScope(styleResolver);
engine->removeFontFaceRules(change.fontFaceRulesToRemove);
styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleSheets);
styleResolver->lazyAppendAuthorStyleSheets(0, collection.activeAuthorStyleSheets());
} else {
styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), collection.activeAuthorStyleSheets());
}
}
m_scopingNodesForStyleScoped.didRemoveScopingNodes();
collection.swap(*this);
updateUsesRemUnits();
return change.requiresFullStyleRecalc;
}
}