| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 bool StyleSheetContents::parseString(const String& sheetText) | 75 bool StyleSheetContents::parseString(const String& sheetText) |
| 76 { | 76 { |
| 77 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); | 77 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); |
| 78 BisonCSSParser p(context); | 78 BisonCSSParser p(context); |
| 79 p.parseSheet(this, sheetText); | 79 p.parseSheet(this, sheetText); |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void StyleSheetContents::registerClient(CSSStyleSheet* sheet) | 83 void StyleSheetContents::registerClient(CSSStyleSheet* sheet) |
| 84 { | 84 { |
| 85 ASSERT(!m_loadingClients.contains(sheet) && !m_completedClients.contains(she
et)); | 85 ASSERT(!m_clients.contains(sheet)); |
| 86 | 86 |
| 87 // InspectorCSSAgent::buildObjectForRule creates CSSStyleSheet without any o
wner node. | 87 // InspectorCSSAgent::buildObjectForRule creates CSSStyleSheet without any o
wner node. |
| 88 if (!sheet->ownerDocument()) | 88 if (!sheet->ownerDocument()) |
| 89 return; | 89 return; |
| 90 m_loadingClients.add(sheet); | 90 m_clients.add(sheet); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void StyleSheetContents::unregisterClient(CSSStyleSheet* sheet) | 93 void StyleSheetContents::unregisterClient(CSSStyleSheet* sheet) |
| 94 { | 94 { |
| 95 m_loadingClients.remove(sheet); | 95 m_clients.remove(sheet); |
| 96 m_completedClients.remove(sheet); | |
| 97 | 96 |
| 98 if (!sheet->ownerDocument() || !m_loadingClients.isEmpty() || !m_completedCl
ients.isEmpty()) | 97 if (!sheet->ownerDocument() || !m_clients.isEmpty()) |
| 99 return; | 98 return; |
| 100 sheet->ownerDocument()->styleEngine()->removeSheet(this); | 99 sheet->ownerDocument()->styleEngine()->removeSheet(this); |
| 101 } | 100 } |
| 102 | 101 |
| 103 void StyleSheetContents::shrinkToFit() | 102 void StyleSheetContents::shrinkToFit() |
| 104 { | 103 { |
| 105 m_childRules.shrinkToFit(); | 104 m_childRules.shrinkToFit(); |
| 106 } | 105 } |
| 107 | 106 |
| 108 RuleSet& StyleSheetContents::ensureRuleSet(const MediaQueryEvaluator& medium, Ad
dRuleFlags addRuleFlags) | 107 RuleSet& StyleSheetContents::ensureRuleSet(const MediaQueryEvaluator& medium, Ad
dRuleFlags addRuleFlags) |
| 109 { | 108 { |
| 110 if (!m_ruleSet) { | 109 if (!m_ruleSet) { |
| 111 m_ruleSet = RuleSet::create(); | 110 m_ruleSet = RuleSet::create(); |
| 112 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); | 111 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); |
| 113 } | 112 } |
| 114 return *m_ruleSet.get(); | 113 return *m_ruleSet.get(); |
| 115 } | 114 } |
| 116 | 115 |
| 117 static void clearResolvers(HashSet<RawPtr<CSSStyleSheet> >& clients) | |
| 118 { | |
| 119 for (HashSet<RawPtr<CSSStyleSheet> >::iterator it = clients.begin(); it != c
lients.end(); ++it) { | |
| 120 if (Document* document = (*it)->ownerDocument()) | |
| 121 document->styleEngine()->clearResolver(); | |
| 122 } | |
| 123 } | |
| 124 | |
| 125 void StyleSheetContents::clearRuleSet() | 116 void StyleSheetContents::clearRuleSet() |
| 126 { | 117 { |
| 127 // Don't want to clear the StyleResolver if the RuleSet hasn't been created | 118 // Don't want to clear the StyleResolver if the RuleSet hasn't been created |
| 128 // since we only clear the StyleResolver so that it's members are properly | 119 // since we only clear the StyleResolver so that it's members are properly |
| 129 // updated in ScopedStyleResolver::addRulesFromSheet. | 120 // updated in ScopedStyleResolver::addRulesFromSheet. |
| 130 if (!m_ruleSet) | 121 if (!m_ruleSet) |
| 131 return; | 122 return; |
| 132 | 123 |
| 133 // Clearing the ruleSet means we need to recreate the styleResolver data str
uctures. | 124 // Clearing the ruleSet means we need to recreate the styleResolver data str
uctures. |
| 134 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet. | 125 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet. |
| 135 clearResolvers(m_loadingClients); | 126 for (RawPtr<CSSStyleSheet> client : m_clients) { |
| 136 clearResolvers(m_completedClients); | 127 if (Document* document = client->ownerDocument()) |
| 128 document->styleEngine()->clearResolver(); |
| 129 } |
| 137 m_ruleSet.clear(); | 130 m_ruleSet.clear(); |
| 138 } | 131 } |
| 139 | 132 |
| 140 static void removeFontFaceRules(HashSet<RawPtr<CSSStyleSheet> >& clients, const
StyleRuleFontFace* fontFaceRule) | |
| 141 { | |
| 142 for (HashSet<RawPtr<CSSStyleSheet> >::iterator it = clients.begin(); it != c
lients.end(); ++it) { | |
| 143 if (Node* ownerNode = (*it)->ownerNode()) | |
| 144 ownerNode->document().styleEngine()->removeFontFaceRules(Vector<RawP
tr<const StyleRuleFontFace> >(1, fontFaceRule)); | |
| 145 } | |
| 146 } | 133 } |
| 147 | |
| 148 void StyleSheetContents::notifyRemoveFontFaceRule(const StyleRuleFontFace* fontF
aceRule) | |
| 149 { | |
| 150 removeFontFaceRules(m_loadingClients, fontFaceRule); | |
| 151 removeFontFaceRules(m_completedClients, fontFaceRule); | |
| 152 } | |
| 153 | |
| 154 } | |
| OLD | NEW |