| OLD | NEW |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 void StyleSheetCollection::removeStyleSheetCandidateNode(Node* node, ContainerNo
de* scopingNode) | 70 void StyleSheetCollection::removeStyleSheetCandidateNode(Node* node, ContainerNo
de* scopingNode) |
| 71 { | 71 { |
| 72 m_styleSheetCandidateNodes.remove(node); | 72 m_styleSheetCandidateNodes.remove(node); |
| 73 | 73 |
| 74 if (!isTreeScopeRoot(scopingNode)) | 74 if (!isTreeScopeRoot(scopingNode)) |
| 75 m_scopingNodesForStyleScoped.remove(scopingNode); | 75 m_scopingNodesForStyleScoped.remove(scopingNode); |
| 76 } | 76 } |
| 77 | 77 |
| 78 StyleSheetCollection::StyleResolverUpdateType StyleSheetCollection::compareStyle
Sheets(const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, const Vector<RefPtr
<CSSStyleSheet> >& newStylesheets, Vector<StyleSheetContents*>& addedSheets) | 78 StyleSheetCollection::StyleResolverUpdateType StyleSheetCollection::compareStyle
Sheets(const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, const Vector<RefPtr
<CSSStyleSheet> >& newStylesheets, Vector<StyleSheetContents*>& addedSheets) |
| 79 { | 79 { |
| 80 // Find out which stylesheets are new. | |
| 81 unsigned newStylesheetCount = newStylesheets.size(); | 80 unsigned newStylesheetCount = newStylesheets.size(); |
| 82 unsigned oldStylesheetCount = oldStyleSheets.size(); | 81 unsigned oldStylesheetCount = oldStyleSheets.size(); |
| 83 if (newStylesheetCount < oldStylesheetCount) | 82 ASSERT(newStylesheetCount >= oldStylesheetCount); |
| 84 return Reconstruct; | |
| 85 | 83 |
| 86 unsigned newIndex = 0; | 84 unsigned newIndex = 0; |
| 87 for (unsigned oldIndex = 0; oldIndex < oldStylesheetCount; ++oldIndex) { | 85 for (unsigned oldIndex = 0; oldIndex < oldStylesheetCount; ++oldIndex) { |
| 88 if (newIndex >= newStylesheetCount) | 86 if (newIndex >= newStylesheetCount) |
| 89 return Reconstruct; | 87 return Reconstruct; |
| 90 while (oldStyleSheets[oldIndex] != newStylesheets[newIndex]) { | 88 while (oldStyleSheets[oldIndex] != newStylesheets[newIndex]) { |
| 91 addedSheets.append(newStylesheets[newIndex]->contents()); | 89 addedSheets.append(newStylesheets[newIndex]->contents()); |
| 92 ++newIndex; | 90 ++newIndex; |
| 93 if (newIndex == newStylesheetCount) | 91 if (newIndex == newStylesheetCount) |
| 94 return Reconstruct; | 92 return Reconstruct; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 if (activeLoadingStyleSheetLoaded(newStyleSheets)) | 128 if (activeLoadingStyleSheetLoaded(newStyleSheets)) |
| 131 return; | 129 return; |
| 132 | 130 |
| 133 if (updateMode != AnalyzedStyleUpdate) | 131 if (updateMode != AnalyzedStyleUpdate) |
| 134 return; | 132 return; |
| 135 if (!document()->styleResolverIfExists()) | 133 if (!document()->styleResolverIfExists()) |
| 136 return; | 134 return; |
| 137 | 135 |
| 138 // Find out which stylesheets are new. | 136 // Find out which stylesheets are new. |
| 139 Vector<StyleSheetContents*> addedSheets; | 137 Vector<StyleSheetContents*> addedSheets; |
| 140 styleResolverUpdateType = compareStyleSheets(oldStyleSheets, newStyleSheets,
addedSheets); | 138 if (oldStyleSheets.size() <= newStyleSheets.size()) { |
| 139 styleResolverUpdateType = compareStyleSheets(oldStyleSheets, newStyleShe
ets, addedSheets); |
| 140 } else { |
| 141 StyleResolverUpdateType updateType = compareStyleSheets(newStyleSheets,
oldStyleSheets, addedSheets); |
| 142 styleResolverUpdateType = updateType != Additive ? updateType : Reset; |
| 143 } |
| 141 | 144 |
| 142 // FIXME: If styleResolverUpdateType is still Reconstruct, we could return e
arly here | 145 // FIXME: If styleResolverUpdateType is still Reconstruct, we could return e
arly here |
| 143 // as destroying the StyleResolver will recalc the whole document anyway? | 146 // as destroying the StyleResolver will recalc the whole document anyway? |
| 144 | 147 |
| 145 // If we are already parsing the body and so may have significant amount of
elements, put some effort into trying to avoid style recalcs. | 148 // If we are already parsing the body and so may have significant amount of
elements, put some effort into trying to avoid style recalcs. |
| 146 if (!document()->body() || document()->hasNodesWithPlaceholderStyle()) | 149 if (!document()->body() || document()->hasNodesWithPlaceholderStyle()) |
| 147 return; | 150 return; |
| 148 StyleInvalidationAnalysis invalidationAnalysis(addedSheets); | 151 StyleInvalidationAnalysis invalidationAnalysis(addedSheets); |
| 149 if (invalidationAnalysis.dirtiesAllStyle()) | 152 if (invalidationAnalysis.dirtiesAllStyle()) |
| 150 return; | 153 return; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 174 } | 177 } |
| 175 return false; | 178 return false; |
| 176 } | 179 } |
| 177 | 180 |
| 178 void StyleSheetCollection::updateUsesRemUnits() | 181 void StyleSheetCollection::updateUsesRemUnits() |
| 179 { | 182 { |
| 180 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); | 183 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); |
| 181 } | 184 } |
| 182 | 185 |
| 183 } | 186 } |
| OLD | NEW |