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 25 matching lines...) Expand all Loading... |
36 #include "platform/RuntimeEnabledFeatures.h" | 36 #include "platform/RuntimeEnabledFeatures.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 DocumentStyleSheetCollection::DocumentStyleSheetCollection(TreeScope& treeScope) | 40 DocumentStyleSheetCollection::DocumentStyleSheetCollection(TreeScope& treeScope) |
41 : TreeScopeStyleSheetCollection(treeScope) | 41 : TreeScopeStyleSheetCollection(treeScope) |
42 { | 42 { |
43 ASSERT(treeScope.rootNode() == treeScope.rootNode().document()); | 43 ASSERT(treeScope.rootNode() == treeScope.rootNode().document()); |
44 } | 44 } |
45 | 45 |
46 void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(StyleEngine*
engine, DocumentStyleSheetCollector& collector) | 46 void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates(StyleEngine&
engine, DocumentStyleSheetCollector& collector) |
47 { | 47 { |
48 for (Node* n : m_styleSheetCandidateNodes) { | 48 for (Node* n : m_styleSheetCandidateNodes) { |
49 StyleSheetCandidate candidate(*n); | 49 StyleSheetCandidate candidate(*n); |
50 | 50 |
51 ASSERT(!candidate.isXSL()); | 51 ASSERT(!candidate.isXSL()); |
52 if (candidate.isImport()) { | 52 if (candidate.isImport()) { |
53 Document* document = candidate.importedDocument(); | 53 Document* document = candidate.importedDocument(); |
54 if (!document) | 54 if (!document) |
55 continue; | 55 continue; |
56 if (collector.hasVisited(document)) | 56 if (collector.hasVisited(document)) |
57 continue; | 57 continue; |
58 collector.willVisit(document); | 58 collector.willVisit(document); |
59 document->styleEngine()->updateStyleSheetsInImport(collector); | 59 document->styleEngine().updateStyleSheetsInImport(collector); |
60 continue; | 60 continue; |
61 } | 61 } |
62 | 62 |
63 if (candidate.isEnabledAndLoading()) { | 63 if (candidate.isEnabledAndLoading()) { |
64 // it is loading but we should still decide which style sheet set to
use | 64 // it is loading but we should still decide which style sheet set to
use |
65 if (candidate.hasPreferrableName(engine->preferredStylesheetSetName(
))) | 65 if (candidate.hasPreferrableName(engine.preferredStylesheetSetName()
)) |
66 engine->selectStylesheetSetName(candidate.title()); | 66 engine.selectStylesheetSetName(candidate.title()); |
67 continue; | 67 continue; |
68 } | 68 } |
69 | 69 |
70 StyleSheet* sheet = candidate.sheet(); | 70 StyleSheet* sheet = candidate.sheet(); |
71 if (!sheet) | 71 if (!sheet) |
72 continue; | 72 continue; |
73 | 73 |
74 if (candidate.hasPreferrableName(engine->preferredStylesheetSetName())) | 74 if (candidate.hasPreferrableName(engine.preferredStylesheetSetName())) |
75 engine->selectStylesheetSetName(candidate.title()); | 75 engine.selectStylesheetSetName(candidate.title()); |
76 collector.appendSheetForList(sheet); | 76 collector.appendSheetForList(sheet); |
77 if (candidate.canBeActivated(engine->preferredStylesheetSetName())) | 77 if (candidate.canBeActivated(engine.preferredStylesheetSetName())) |
78 collector.appendActiveStyleSheet(toCSSStyleSheet(sheet)); | 78 collector.appendActiveStyleSheet(toCSSStyleSheet(sheet)); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 void DocumentStyleSheetCollection::collectStyleSheets(StyleEngine* engine, Docum
entStyleSheetCollector& collector) | 82 void DocumentStyleSheetCollection::collectStyleSheets(StyleEngine& engine, Docum
entStyleSheetCollector& collector) |
83 { | 83 { |
84 ASSERT(document().styleEngine() == engine); | 84 ASSERT(&document().styleEngine() == &engine); |
85 collector.appendActiveStyleSheets(engine->injectedAuthorStyleSheets()); | 85 collector.appendActiveStyleSheets(engine.injectedAuthorStyleSheets()); |
86 collector.appendActiveStyleSheets(engine->documentAuthorStyleSheets()); | 86 collector.appendActiveStyleSheets(engine.documentAuthorStyleSheets()); |
87 collectStyleSheetsFromCandidates(engine, collector); | 87 collectStyleSheetsFromCandidates(engine, collector); |
88 } | 88 } |
89 | 89 |
90 void DocumentStyleSheetCollection::updateActiveStyleSheets(StyleEngine* engine,
StyleResolverUpdateMode updateMode) | 90 void DocumentStyleSheetCollection::updateActiveStyleSheets(StyleEngine& engine,
StyleResolverUpdateMode updateMode) |
91 { | 91 { |
92 StyleSheetCollection collection; | 92 StyleSheetCollection collection; |
93 ActiveDocumentStyleSheetCollector collector(collection); | 93 ActiveDocumentStyleSheetCollector collector(collection); |
94 collectStyleSheets(engine, collector); | 94 collectStyleSheets(engine, collector); |
95 | 95 |
96 StyleSheetChange change; | 96 StyleSheetChange change; |
97 analyzeStyleSheetChange(updateMode, collection, change); | 97 analyzeStyleSheetChange(updateMode, collection, change); |
98 | 98 |
99 if (change.styleResolverUpdateType == Reconstruct) { | 99 if (change.styleResolverUpdateType == Reconstruct) { |
100 engine->clearMasterResolver(); | 100 engine.clearMasterResolver(); |
101 // FIMXE: The following depends on whether StyleRuleFontFace was modifie
d or not. | 101 // FIMXE: The following depends on whether StyleRuleFontFace was modifie
d or not. |
102 // No need to always-clear font cache. | 102 // No need to always-clear font cache. |
103 engine->clearFontCache(); | 103 engine.clearFontCache(); |
104 } else if (StyleResolver* styleResolver = engine->resolver()) { | 104 } else if (StyleResolver* styleResolver = engine.resolver()) { |
105 if (change.styleResolverUpdateType != Additive) { | 105 if (change.styleResolverUpdateType != Additive) { |
106 ASSERT(change.styleResolverUpdateType == Reset); | 106 ASSERT(change.styleResolverUpdateType == Reset); |
107 styleResolver->resetAuthorStyle(treeScope()); | 107 styleResolver->resetAuthorStyle(treeScope()); |
108 engine->removeFontFaceRules(change.fontFaceRulesToRemove); | 108 engine.removeFontFaceRules(change.fontFaceRulesToRemove); |
109 styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleShe
ets); | 109 styleResolver->removePendingAuthorStyleSheets(m_activeAuthorStyleShe
ets); |
110 styleResolver->lazyAppendAuthorStyleSheets(0, collection.activeAutho
rStyleSheets()); | 110 styleResolver->lazyAppendAuthorStyleSheets(0, collection.activeAutho
rStyleSheets()); |
111 } else { | 111 } else { |
112 styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets
.size(), collection.activeAuthorStyleSheets()); | 112 styleResolver->lazyAppendAuthorStyleSheets(m_activeAuthorStyleSheets
.size(), collection.activeAuthorStyleSheets()); |
113 } | 113 } |
114 } | 114 } |
115 if (change.requiresFullStyleRecalc) | 115 if (change.requiresFullStyleRecalc) |
116 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForT
racing::create(StyleChangeReason::ActiveStylesheetsUpdate)); | 116 document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForT
racing::create(StyleChangeReason::ActiveStylesheetsUpdate)); |
117 | 117 |
118 collection.swap(*this); | 118 collection.swap(*this); |
119 | 119 |
120 updateUsesRemUnits(); | 120 updateUsesRemUnits(); |
121 } | 121 } |
122 | 122 |
123 } | 123 } |
OLD | NEW |