| Index: Source/core/dom/StyleSheetCollection.cpp
|
| diff --git a/Source/core/dom/StyleSheetCollection.cpp b/Source/core/dom/StyleSheetCollection.cpp
|
| index 03e6611bddd5076581ea98d83102ea1a710772f2..c25f30e12ecf86a52a5ac4b6f91a970a2b99e65f 100644
|
| --- a/Source/core/dom/StyleSheetCollection.cpp
|
| +++ b/Source/core/dom/StyleSheetCollection.cpp
|
| @@ -133,7 +133,7 @@ StyleSheetCollection::StyleResolverUpdateType StyleSheetCollection::compareStyle
|
| }
|
| // If all new sheets were added at the end of the list we can just add them to existing StyleResolver.
|
| // If there were insertions we need to re-add all the stylesheets so rules are ordered correctly.
|
| - return hasInsertions ? Reset : Additive;
|
| + return hasInsertions ? Reconstruct : Additive;
|
| }
|
|
|
| bool StyleSheetCollection::activeLoadingStyleSheetLoaded(const Vector<RefPtr<CSSStyleSheet> >& newStyleSheets)
|
| @@ -153,26 +153,6 @@ bool StyleSheetCollection::activeLoadingStyleSheetLoaded(const Vector<RefPtr<CSS
|
| return false;
|
| }
|
|
|
| -static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets)
|
| -{
|
| - for (unsigned i = 0; i < sheets.size(); ++i) {
|
| - ASSERT(sheets[i]);
|
| - if (sheets[i]->hasFontFaceRule())
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| -static bool cssStyleSheetHasFontFaceRule(const Vector<RefPtr<CSSStyleSheet> > sheets)
|
| -{
|
| - for (unsigned i = 0; i < sheets.size(); ++i) {
|
| - ASSERT(sheets[i]);
|
| - if (sheets[i]->contents()->hasFontFaceRule())
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updateMode, const StyleSheetCollectionBase& newCollection, StyleSheetChange& change)
|
| {
|
| if (activeLoadingStyleSheetLoaded(newCollection.activeAuthorStyleSheets()))
|
| @@ -183,31 +163,10 @@ void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat
|
|
|
| // Find out which stylesheets are new.
|
| Vector<StyleSheetContents*> addedSheets;
|
| - if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheets().size()) {
|
| + if (m_activeAuthorStyleSheets.size() <= newCollection.activeAuthorStyleSheets().size())
|
| change.styleResolverUpdateType = compareStyleSheets(m_activeAuthorStyleSheets, newCollection.activeAuthorStyleSheets(), addedSheets);
|
| - } else {
|
| - StyleResolverUpdateType updateType = compareStyleSheets(newCollection.activeAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets);
|
| - if (updateType != Additive) {
|
| - change.styleResolverUpdateType = updateType;
|
| - } else {
|
| - if (styleSheetContentsHasFontFaceRule(addedSheets)) {
|
| - change.styleResolverUpdateType = ResetStyleResolverAndFontSelector;
|
| - return;
|
| - }
|
| - // FIXME: since currently all stylesheets are re-added after reseting styleresolver,
|
| - // fontSelector should be always reset. After creating RuleSet for each StyleSheetContents,
|
| - // we can avoid appending all stylesheetcontents in reset case.
|
| - // So we can remove "styleSheetContentsHasFontFaceRule(newSheets)".
|
| - if (cssStyleSheetHasFontFaceRule(newCollection.activeAuthorStyleSheets()))
|
| - change.styleResolverUpdateType = ResetStyleResolverAndFontSelector;
|
| - else
|
| - change.styleResolverUpdateType = Reset;
|
| - }
|
| - }
|
| -
|
| - // FIXME: If styleResolverUpdateType is Reconstruct, we should return early here since
|
| - // we need to recalc the whole document. It's wrong to use StyleInvalidationAnalysis since
|
| - // it only looks at the addedSheets.
|
| + else
|
| + compareStyleSheets(newCollection.activeAuthorStyleSheets(), m_activeAuthorStyleSheets, addedSheets);
|
|
|
| // If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs.
|
| if (!document()->body() || document()->hasNodesWithPlaceholderStyle())
|
| @@ -229,20 +188,6 @@ void StyleSheetCollection::clearMediaQueryRuleSetStyleSheets()
|
| }
|
| }
|
|
|
| -void StyleSheetCollection::resetAllRuleSetsInTreeScope(StyleResolver* styleResolver)
|
| -{
|
| - // FIXME: If many web developers use style scoped, implement reset RuleSets in per-scoping node manner.
|
| - if (DocumentOrderedList* styleScopedScopingNodes = scopingNodesForStyleScoped()) {
|
| - for (DocumentOrderedList::iterator it = styleScopedScopingNodes->begin(); it != styleScopedScopingNodes->end(); ++it)
|
| - styleResolver->resetAuthorStyle(toContainerNode(*it));
|
| - }
|
| - if (ListHashSet<Node*, 4>* removedNodes = scopingNodesRemoved()) {
|
| - for (ListHashSet<Node*, 4>::iterator it = removedNodes->begin(); it != removedNodes->end(); ++it)
|
| - styleResolver->resetAuthorStyle(toContainerNode(*it));
|
| - }
|
| - styleResolver->resetAuthorStyle(toContainerNode(m_treeScope.rootNode()));
|
| -}
|
| -
|
| static bool styleSheetsUseRemUnits(const Vector<RefPtr<CSSStyleSheet> >& sheets)
|
| {
|
| for (unsigned i = 0; i < sheets.size(); ++i) {
|
| @@ -257,4 +202,29 @@ void StyleSheetCollection::updateUsesRemUnits()
|
| m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets);
|
| }
|
|
|
| +bool StyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine, StyleResolverUpdateMode updateMode)
|
| +{
|
| + StyleSheetCollectionBase collection;
|
| + collectStyleSheets(engine, collection);
|
| +
|
| + StyleSheetChange change;
|
| + analyzeStyleSheetChange(updateMode, collection, change);
|
| +
|
| + if (change.styleResolverUpdateType == Reconstruct) {
|
| + engine->clearResolver();
|
| + } else if (StyleResolver* styleResolver = engine->resolverIfExists()) {
|
| + ASSERT(change.styleResolverUpdateType == Additive);
|
| + // FIXME: We might have already had styles in child treescope. In this case, we cannot use buildScopedStyleTreeInDocumentOrder.
|
| + // Need to change "false" to some valid condition.
|
| + styleResolver->setBuildScopedStyleTreeInDocumentOrder(false);
|
| + styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets.size(), collection.activeAuthorStyleSheets());
|
| + }
|
| +
|
| + m_scopingNodesForStyleScoped.didRemoveScopingNodes();
|
| + collection.swap(*this);
|
| + updateUsesRemUnits();
|
| +
|
| + return change.requiresFullStyleRecalc;
|
| +}
|
| +
|
| }
|
|
|