| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 void TreeScopeStyleSheetCollection::removeStyleSheetCandidateNode(Node* node, Co
ntainerNode* scopingNode) | 70 void TreeScopeStyleSheetCollection::removeStyleSheetCandidateNode(Node* node, Co
ntainerNode* 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 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec
tion::compareStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, c
onst Vector<RefPtr<CSSStyleSheet> >& newStylesheets, WillBeHeapVector<RawPtrWill
BeMember<StyleSheetContents> >& addedSheets) | 78 TreeScopeStyleSheetCollection::StyleResolverUpdateType TreeScopeStyleSheetCollec
tion::compareStyleSheets(const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet
> >& oldStyleSheets, const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >&
newStylesheets, WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents> >& adde
dSheets) |
| 79 { | 79 { |
| 80 unsigned newStyleSheetCount = newStylesheets.size(); | 80 unsigned newStyleSheetCount = newStylesheets.size(); |
| 81 unsigned oldStyleSheetCount = oldStyleSheets.size(); | 81 unsigned oldStyleSheetCount = oldStyleSheets.size(); |
| 82 ASSERT(newStyleSheetCount >= oldStyleSheetCount); | 82 ASSERT(newStyleSheetCount >= oldStyleSheetCount); |
| 83 | 83 |
| 84 if (!newStyleSheetCount) | 84 if (!newStyleSheetCount) |
| 85 return Reconstruct; | 85 return Reconstruct; |
| 86 | 86 |
| 87 unsigned newIndex = 0; | 87 unsigned newIndex = 0; |
| 88 for (unsigned oldIndex = 0; oldIndex < oldStyleSheetCount; ++oldIndex) { | 88 for (unsigned oldIndex = 0; oldIndex < oldStyleSheetCount; ++oldIndex) { |
| 89 while (oldStyleSheets[oldIndex] != newStylesheets[newIndex]) { | 89 while (oldStyleSheets[oldIndex] != newStylesheets[newIndex]) { |
| 90 addedSheets.append(newStylesheets[newIndex]->contents()); | 90 addedSheets.append(newStylesheets[newIndex]->contents()); |
| 91 if (++newIndex == newStyleSheetCount) | 91 if (++newIndex == newStyleSheetCount) |
| 92 return Reconstruct; | 92 return Reconstruct; |
| 93 } | 93 } |
| 94 if (++newIndex == newStyleSheetCount) | 94 if (++newIndex == newStyleSheetCount) |
| 95 return Reconstruct; | 95 return Reconstruct; |
| 96 } | 96 } |
| 97 bool hasInsertions = !addedSheets.isEmpty(); | 97 bool hasInsertions = !addedSheets.isEmpty(); |
| 98 while (newIndex < newStyleSheetCount) { | 98 while (newIndex < newStyleSheetCount) { |
| 99 addedSheets.append(newStylesheets[newIndex]->contents()); | 99 addedSheets.append(newStylesheets[newIndex]->contents()); |
| 100 ++newIndex; | 100 ++newIndex; |
| 101 } | 101 } |
| 102 // If all new sheets were added at the end of the list we can just add them
to existing StyleResolver. | 102 // If all new sheets were added at the end of the list we can just add them
to existing StyleResolver. |
| 103 // If there were insertions we need to re-add all the stylesheets so rules a
re ordered correctly. | 103 // If there were insertions we need to re-add all the stylesheets so rules a
re ordered correctly. |
| 104 return hasInsertions ? Reset : Additive; | 104 return hasInsertions ? Reset : Additive; |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded(const Vector<R
efPtr<CSSStyleSheet> >& newStyleSheets) | 107 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded(const WillBeHe
apVector<RefPtrWillBeMember<CSSStyleSheet> >& newStyleSheets) |
| 108 { | 108 { |
| 109 // StyleSheets of <style> elements that @import stylesheets are active but l
oading. We need to trigger a full recalc when such loads are done. | 109 // StyleSheets of <style> elements that @import stylesheets are active but l
oading. We need to trigger a full recalc when such loads are done. |
| 110 bool hasActiveLoadingStylesheet = false; | 110 bool hasActiveLoadingStylesheet = false; |
| 111 unsigned newStylesheetCount = newStyleSheets.size(); | 111 unsigned newStylesheetCount = newStyleSheets.size(); |
| 112 for (unsigned i = 0; i < newStylesheetCount; ++i) { | 112 for (unsigned i = 0; i < newStylesheetCount; ++i) { |
| 113 if (newStyleSheets[i]->isLoading()) | 113 if (newStyleSheets[i]->isLoading()) |
| 114 hasActiveLoadingStylesheet = true; | 114 hasActiveLoadingStylesheet = true; |
| 115 } | 115 } |
| 116 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { | 116 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { |
| 117 m_hadActiveLoadingStylesheet = false; | 117 m_hadActiveLoadingStylesheet = false; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 for (DocumentOrderedList::iterator it = styleScopedScopingNodes->begin()
; it != styleScopedScopingNodes->end(); ++it) | 197 for (DocumentOrderedList::iterator it = styleScopedScopingNodes->begin()
; it != styleScopedScopingNodes->end(); ++it) |
| 198 styleResolver->resetAuthorStyle(toContainerNode(*it)); | 198 styleResolver->resetAuthorStyle(toContainerNode(*it)); |
| 199 } | 199 } |
| 200 if (ListHashSet<Node*, 4>* removedNodes = scopingNodesRemoved()) { | 200 if (ListHashSet<Node*, 4>* removedNodes = scopingNodesRemoved()) { |
| 201 for (ListHashSet<Node*, 4>::iterator it = removedNodes->begin(); it != r
emovedNodes->end(); ++it) | 201 for (ListHashSet<Node*, 4>::iterator it = removedNodes->begin(); it != r
emovedNodes->end(); ++it) |
| 202 styleResolver->resetAuthorStyle(toContainerNode(*it)); | 202 styleResolver->resetAuthorStyle(toContainerNode(*it)); |
| 203 } | 203 } |
| 204 styleResolver->resetAuthorStyle(toContainerNode(&m_treeScope.rootNode())); | 204 styleResolver->resetAuthorStyle(toContainerNode(&m_treeScope.rootNode())); |
| 205 } | 205 } |
| 206 | 206 |
| 207 static bool styleSheetsUseRemUnits(const Vector<RefPtr<CSSStyleSheet> >& sheets) | 207 static bool styleSheetsUseRemUnits(const WillBeHeapVector<RefPtrWillBeMember<CSS
StyleSheet> >& sheets) |
| 208 { | 208 { |
| 209 for (unsigned i = 0; i < sheets.size(); ++i) { | 209 for (unsigned i = 0; i < sheets.size(); ++i) { |
| 210 if (sheets[i]->contents()->usesRemUnits()) | 210 if (sheets[i]->contents()->usesRemUnits()) |
| 211 return true; | 211 return true; |
| 212 } | 212 } |
| 213 return false; | 213 return false; |
| 214 } | 214 } |
| 215 | 215 |
| 216 void TreeScopeStyleSheetCollection::updateUsesRemUnits() | 216 void TreeScopeStyleSheetCollection::updateUsesRemUnits() |
| 217 { | 217 { |
| 218 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); | 218 m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets); |
| 219 } | 219 } |
| 220 | 220 |
| 221 } | 221 } |
| OLD | NEW |