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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 , m_loadCompleted(false) | 128 , m_loadCompleted(false) |
129 { | 129 { |
130 ASSERT(isAcceptableCSSStyleSheetParent(ownerNode)); | 130 ASSERT(isAcceptableCSSStyleSheetParent(ownerNode)); |
131 m_contents->registerClient(this); | 131 m_contents->registerClient(this); |
132 } | 132 } |
133 | 133 |
134 CSSStyleSheet::~CSSStyleSheet() | 134 CSSStyleSheet::~CSSStyleSheet() |
135 { | 135 { |
136 } | 136 } |
137 | 137 |
| 138 #if ENABLE(ASSERT) |
| 139 |
| 140 static bool isStyleElement(const Node* node) |
| 141 { |
| 142 return node && (isHTMLStyleElement(node) || isSVGStyleElement(node)); |
| 143 } |
| 144 |
| 145 #endif // ENABLE(ASSERT) |
| 146 |
138 void CSSStyleSheet::willMutateRules() | 147 void CSSStyleSheet::willMutateRules() |
139 { | 148 { |
140 // If we are the only client it is safe to mutate. | 149 // If we are the only client it is safe to mutate. |
141 if (m_contents->clientSize() <= 1 && !m_contents->isReferencedFromResource()
) { | 150 if (m_contents->clientSize() <= 1 && !m_contents->isReferencedFromResource()
) { |
142 m_contents->clearRuleSet(); | 151 m_contents->clearRuleSet(); |
143 if (Document* document = ownerDocument()) | 152 if (Document* document = ownerDocument()) |
144 m_contents->removeSheetFromCache(document); | 153 m_contents->removeSheetFromCache(document); |
145 m_contents->setMutable(); | 154 m_contents->setMutable(); |
146 return; | 155 return; |
147 } | 156 } |
148 // Only cacheable stylesheets should have multiple clients. | 157 // Only cacheable stylesheets should have multiple clients. |
149 ASSERT(m_contents->isCacheable()); | 158 ASSERT((isStyleElement(ownerNode()) && m_contents->isCacheableForStyleElemen
t()) |
| 159 || m_contents->isCacheableForResource()); |
150 | 160 |
151 // Copy-on-write. | 161 // Copy-on-write. |
152 m_contents->unregisterClient(this); | 162 m_contents->unregisterClient(this); |
153 m_contents = m_contents->copy(); | 163 m_contents = m_contents->copy(); |
154 m_contents->registerClient(this); | 164 m_contents->registerClient(this); |
155 | 165 |
156 m_contents->setMutable(); | 166 m_contents->setMutable(); |
157 | 167 |
158 // Any existing CSSOM wrappers need to be connected to the copied child rule
s. | 168 // Any existing CSSOM wrappers need to be connected to the copied child rule
s. |
159 reattachChildRuleCSSOMWrappers(); | 169 reattachChildRuleCSSOMWrappers(); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 visitor->trace(m_mediaQueries); | 440 visitor->trace(m_mediaQueries); |
431 visitor->trace(m_ownerNode); | 441 visitor->trace(m_ownerNode); |
432 visitor->trace(m_ownerRule); | 442 visitor->trace(m_ownerRule); |
433 visitor->trace(m_mediaCSSOMWrapper); | 443 visitor->trace(m_mediaCSSOMWrapper); |
434 visitor->trace(m_childRuleCSSOMWrappers); | 444 visitor->trace(m_childRuleCSSOMWrappers); |
435 visitor->trace(m_ruleListCSSOMWrapper); | 445 visitor->trace(m_ruleListCSSOMWrapper); |
436 StyleSheet::trace(visitor); | 446 StyleSheet::trace(visitor); |
437 } | 447 } |
438 | 448 |
439 } // namespace blink | 449 } // namespace blink |
OLD | NEW |