| 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 | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "core/dom/StyleSheetCandidate.h" | 38 #include "core/dom/StyleSheetCandidate.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 DocumentStyleSheetCollection::DocumentStyleSheetCollection(TreeScope& treeScope) | 42 DocumentStyleSheetCollection::DocumentStyleSheetCollection(TreeScope& treeScope) |
| 43 : TreeScopeStyleSheetCollection(treeScope) { | 43 : TreeScopeStyleSheetCollection(treeScope) { |
| 44 DCHECK_EQ(treeScope.rootNode(), treeScope.rootNode().document()); | 44 DCHECK_EQ(treeScope.rootNode(), treeScope.rootNode().document()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates( | 47 void DocumentStyleSheetCollection::collectStyleSheetsFromCandidates( |
| 48 StyleEngine& masterEngine, |
| 48 DocumentStyleSheetCollector& collector) { | 49 DocumentStyleSheetCollector& collector) { |
| 49 for (Node* n : m_styleSheetCandidateNodes) { | 50 for (Node* n : m_styleSheetCandidateNodes) { |
| 50 StyleSheetCandidate candidate(*n); | 51 StyleSheetCandidate candidate(*n); |
| 51 | 52 |
| 52 DCHECK(!candidate.isXSL()); | 53 DCHECK(!candidate.isXSL()); |
| 53 if (candidate.isImport()) { | 54 if (candidate.isImport()) { |
| 54 Document* document = candidate.importedDocument(); | 55 Document* document = candidate.importedDocument(); |
| 55 if (!document) | 56 if (!document) |
| 56 continue; | 57 continue; |
| 57 if (collector.hasVisited(document)) | 58 if (collector.hasVisited(document)) |
| 58 continue; | 59 continue; |
| 59 collector.willVisit(document); | 60 collector.willVisit(document); |
| 60 document->styleEngine().updateStyleSheetsInImport(collector); | 61 |
| 62 document->styleEngine().updateStyleSheetsInImport(masterEngine, |
| 63 collector); |
| 61 continue; | 64 continue; |
| 62 } | 65 } |
| 63 | 66 |
| 64 if (candidate.isEnabledAndLoading()) | 67 if (candidate.isEnabledAndLoading()) |
| 65 continue; | 68 continue; |
| 66 | 69 |
| 67 StyleSheet* sheet = candidate.sheet(); | 70 StyleSheet* sheet = candidate.sheet(); |
| 68 if (!sheet) | 71 if (!sheet) |
| 69 continue; | 72 continue; |
| 70 | 73 |
| 71 collector.appendSheetForList(sheet); | 74 collector.appendSheetForList(sheet); |
| 72 if (!candidate.canBeActivated( | 75 if (!candidate.canBeActivated( |
| 73 document().styleEngine().preferredStylesheetSetName())) | 76 document().styleEngine().preferredStylesheetSetName())) |
| 74 continue; | 77 continue; |
| 75 | 78 |
| 76 CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet); | 79 CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet); |
| 77 collector.appendActiveStyleSheet(std::make_pair( | 80 collector.appendActiveStyleSheet( |
| 78 cssSheet, document().styleEngine().ruleSetForSheet(*cssSheet))); | 81 std::make_pair(cssSheet, masterEngine.ruleSetForSheet(*cssSheet))); |
| 79 } | 82 } |
| 80 } | 83 } |
| 81 | 84 |
| 82 void DocumentStyleSheetCollection::collectStyleSheets( | 85 void DocumentStyleSheetCollection::collectStyleSheets( |
| 86 StyleEngine& masterEngine, |
| 83 DocumentStyleSheetCollector& collector) { | 87 DocumentStyleSheetCollector& collector) { |
| 84 for (auto& sheet : document().styleEngine().injectedAuthorStyleSheets()) { | 88 for (auto& sheet : document().styleEngine().injectedAuthorStyleSheets()) { |
| 85 collector.appendActiveStyleSheet(std::make_pair( | 89 collector.appendActiveStyleSheet(std::make_pair( |
| 86 sheet, document().styleEngine().ruleSetForSheet(*sheet))); | 90 sheet, document().styleEngine().ruleSetForSheet(*sheet))); |
| 87 } | 91 } |
| 88 collectStyleSheetsFromCandidates(collector); | 92 collectStyleSheetsFromCandidates(masterEngine, collector); |
| 89 if (CSSStyleSheet* inspectorSheet = | 93 if (CSSStyleSheet* inspectorSheet = |
| 90 document().styleEngine().inspectorStyleSheet()) { | 94 document().styleEngine().inspectorStyleSheet()) { |
| 91 collector.appendActiveStyleSheet(std::make_pair( | 95 collector.appendActiveStyleSheet(std::make_pair( |
| 92 inspectorSheet, | 96 inspectorSheet, |
| 93 document().styleEngine().ruleSetForSheet(*inspectorSheet))); | 97 document().styleEngine().ruleSetForSheet(*inspectorSheet))); |
| 94 } | 98 } |
| 95 } | 99 } |
| 96 | 100 |
| 97 void DocumentStyleSheetCollection::updateActiveStyleSheets() { | 101 void DocumentStyleSheetCollection::updateActiveStyleSheets( |
| 102 StyleEngine& masterEngine) { |
| 98 // StyleSheetCollection is GarbageCollected<>, allocate it on the heap. | 103 // StyleSheetCollection is GarbageCollected<>, allocate it on the heap. |
| 99 StyleSheetCollection* collection = StyleSheetCollection::create(); | 104 StyleSheetCollection* collection = StyleSheetCollection::create(); |
| 100 ActiveDocumentStyleSheetCollector collector(*collection); | 105 ActiveDocumentStyleSheetCollector collector(*collection); |
| 101 collectStyleSheets(collector); | 106 collectStyleSheets(masterEngine, collector); |
| 102 applyActiveStyleSheetChanges(*collection); | 107 applyActiveStyleSheetChanges(*collection); |
| 103 } | 108 } |
| 104 | 109 |
| 105 void DocumentStyleSheetCollection::collectViewportRules( | 110 void DocumentStyleSheetCollection::collectViewportRules( |
| 106 ViewportStyleResolver& viewportResolver) { | 111 ViewportStyleResolver& viewportResolver) { |
| 107 for (Node* node : m_styleSheetCandidateNodes) { | 112 for (Node* node : m_styleSheetCandidateNodes) { |
| 108 StyleSheetCandidate candidate(*node); | 113 StyleSheetCandidate candidate(*node); |
| 109 | 114 |
| 110 if (candidate.isImport()) | 115 if (candidate.isImport()) |
| 111 continue; | 116 continue; |
| 112 StyleSheet* sheet = candidate.sheet(); | 117 StyleSheet* sheet = candidate.sheet(); |
| 113 if (!sheet) | 118 if (!sheet) |
| 114 continue; | 119 continue; |
| 115 if (!candidate.canBeActivated( | 120 if (!candidate.canBeActivated( |
| 116 document().styleEngine().preferredStylesheetSetName())) | 121 document().styleEngine().preferredStylesheetSetName())) |
| 117 continue; | 122 continue; |
| 118 viewportResolver.collectViewportRulesFromAuthorSheet( | 123 viewportResolver.collectViewportRulesFromAuthorSheet( |
| 119 *toCSSStyleSheet(sheet)); | 124 *toCSSStyleSheet(sheet)); |
| 120 } | 125 } |
| 121 } | 126 } |
| 122 | 127 |
| 123 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |