This source file includes following definitions.
- collectStyleSheets
- updateActiveStyleSheets
#include "config.h"
#include "core/dom/ShadowTreeStyleSheetCollection.h"
#include "HTMLNames.h"
#include "core/css/CSSStyleSheet.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/Element.h"
#include "core/dom/StyleEngine.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/html/HTMLStyleElement.h"
namespace WebCore {
using namespace HTMLNames;
ShadowTreeStyleSheetCollection::ShadowTreeStyleSheetCollection(ShadowRoot& shadowRoot)
: TreeScopeStyleSheetCollection(shadowRoot)
{
}
void ShadowTreeStyleSheetCollection::collectStyleSheets(StyleEngine* engine, StyleSheetCollection& collection)
{
DocumentOrderedList::iterator begin = m_styleSheetCandidateNodes.begin();
DocumentOrderedList::iterator end = m_styleSheetCandidateNodes.end();
for (DocumentOrderedList::iterator it = begin; it != end; ++it) {
Node* node = *it;
StyleSheet* sheet = 0;
CSSStyleSheet* activeSheet = 0;
if (!isHTMLStyleElement(*node))
continue;
HTMLStyleElement* element = toHTMLStyleElement(node);
const AtomicString& title = element->fastGetAttribute(titleAttr);
bool enabledViaScript = false;
sheet = element->sheet();
if (sheet && !sheet->disabled() && sheet->isCSSStyleSheet())
activeSheet = toCSSStyleSheet(sheet);
if (!enabledViaScript && sheet && !title.isEmpty()) {
if (engine->preferredStylesheetSetName().isEmpty()) {
engine->setPreferredStylesheetSetName(title);
engine->setSelectedStylesheetSetName(title);
}
if (title != engine->preferredStylesheetSetName())
activeSheet = 0;
}
const AtomicString& rel = element->fastGetAttribute(relAttr);
if (rel.contains("alternate") && title.isEmpty())
activeSheet = 0;
if (sheet)
collection.appendSheetForList(sheet);
if (activeSheet)
collection.appendActiveStyleSheet(activeSheet);
}
}
bool ShadowTreeStyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine, StyleResolverUpdateMode updateMode)
{
StyleSheetCollection collection;
collectStyleSheets(engine, collection);
StyleSheetChange change;
analyzeStyleSheetChange(updateMode, collection, change);
if (StyleResolver* styleResolver = engine->resolver()) {
styleResolver->setBuildScopedStyleTreeInDocumentOrder(false);
if (change.styleResolverUpdateType != Additive) {
resetAllRuleSetsInTreeScope(styleResolver);
styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleSheets);
styleResolver->lazyAppendAuthorStyleSheets(0, collection.activeAuthorStyleSheets());
} else {
styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), collection.activeAuthorStyleSheets());
}
}
if (change.requiresFullStyleRecalc)
toShadowRoot(m_treeScope.rootNode()).host()->setNeedsStyleRecalc(SubtreeStyleChange);
m_scopingNodesForStyleScoped.didRemoveScopingNodes();
collection.swap(*this);
updateUsesRemUnits();
return change.requiresFullStyleRecalc;
}
}