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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 m_contents->setMutable(); | 152 m_contents->setMutable(); |
153 | 153 |
154 // Any existing CSSOM wrappers need to be connected to the copied child rules. | 154 // Any existing CSSOM wrappers need to be connected to the copied child rules. |
155 reattachChildRuleCSSOMWrappers(); | 155 reattachChildRuleCSSOMWrappers(); |
156 } | 156 } |
157 | 157 |
158 void CSSStyleSheet::didMutateRules() { | 158 void CSSStyleSheet::didMutateRules() { |
159 DCHECK(m_contents->isMutable()); | 159 DCHECK(m_contents->isMutable()); |
160 DCHECK_LE(m_contents->clientSize(), 1u); | 160 DCHECK_LE(m_contents->clientSize(), 1u); |
161 | 161 |
162 didMutate(PartialRuleUpdate); | 162 didMutate(); |
163 } | 163 } |
164 | 164 |
165 void CSSStyleSheet::didMutate(StyleSheetUpdateType updateType) { | 165 void CSSStyleSheet::didMutate() { |
166 Document* owner = ownerDocument(); | 166 Document* owner = ownerDocument(); |
167 if (!owner) | 167 if (!owner) |
168 return; | 168 return; |
169 if (ownerNode() && ownerNode()->isConnected()) | 169 if (ownerNode() && ownerNode()->isConnected()) |
170 owner->styleEngine().setNeedsActiveStyleUpdate(ownerNode()->treeScope()); | 170 owner->styleEngine().setNeedsActiveStyleUpdate(ownerNode()->treeScope()); |
171 | |
172 // TODO(rune@opera.com): resolverChanged() can be removed once stylesheet | |
173 // updates are async. https://crbug.com/567021 | |
174 | |
175 // Need FullStyleUpdate when insertRule or deleteRule, | |
176 // because StyleSheetCollection::analyzeStyleSheetChange cannot detect partial | |
177 // rule update. | |
178 StyleResolverUpdateMode updateMode = | |
179 updateType != PartialRuleUpdate ? AnalyzedStyleUpdate : FullStyleUpdate; | |
180 owner->styleEngine().resolverChanged(updateMode); | |
181 } | 171 } |
182 | 172 |
183 void CSSStyleSheet::reattachChildRuleCSSOMWrappers() { | 173 void CSSStyleSheet::reattachChildRuleCSSOMWrappers() { |
184 for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) { | 174 for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) { |
185 if (!m_childRuleCSSOMWrappers[i]) | 175 if (!m_childRuleCSSOMWrappers[i]) |
186 continue; | 176 continue; |
187 m_childRuleCSSOMWrappers[i]->reattach(m_contents->ruleAt(i)); | 177 m_childRuleCSSOMWrappers[i]->reattach(m_contents->ruleAt(i)); |
188 } | 178 } |
189 } | 179 } |
190 | 180 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 m_childRuleCSSOMWrappers.grow(ruleCount); | 215 m_childRuleCSSOMWrappers.grow(ruleCount); |
226 DCHECK_EQ(m_childRuleCSSOMWrappers.size(), ruleCount); | 216 DCHECK_EQ(m_childRuleCSSOMWrappers.size(), ruleCount); |
227 | 217 |
228 Member<CSSRule>& cssRule = m_childRuleCSSOMWrappers[index]; | 218 Member<CSSRule>& cssRule = m_childRuleCSSOMWrappers[index]; |
229 if (!cssRule) | 219 if (!cssRule) |
230 cssRule = m_contents->ruleAt(index)->createCSSOMWrapper(this); | 220 cssRule = m_contents->ruleAt(index)->createCSSOMWrapper(this); |
231 return cssRule.get(); | 221 return cssRule.get(); |
232 } | 222 } |
233 | 223 |
234 void CSSStyleSheet::clearOwnerNode() { | 224 void CSSStyleSheet::clearOwnerNode() { |
235 didMutate(EntireStyleSheetUpdate); | 225 didMutate(); |
236 if (m_ownerNode) | 226 if (m_ownerNode) |
237 m_contents->unregisterClient(this); | 227 m_contents->unregisterClient(this); |
238 m_ownerNode = nullptr; | 228 m_ownerNode = nullptr; |
239 } | 229 } |
240 | 230 |
241 bool CSSStyleSheet::canAccessRules() const { | 231 bool CSSStyleSheet::canAccessRules() const { |
242 if (m_isInlineStylesheet) | 232 if (m_isInlineStylesheet) |
243 return true; | 233 return true; |
244 KURL baseURL = m_contents->baseURL(); | 234 KURL baseURL = m_contents->baseURL(); |
245 if (baseURL.isEmpty()) | 235 if (baseURL.isEmpty()) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 visitor->trace(m_deviceDependentMediaQueryResults); | 433 visitor->trace(m_deviceDependentMediaQueryResults); |
444 visitor->trace(m_ownerNode); | 434 visitor->trace(m_ownerNode); |
445 visitor->trace(m_ownerRule); | 435 visitor->trace(m_ownerRule); |
446 visitor->trace(m_mediaCSSOMWrapper); | 436 visitor->trace(m_mediaCSSOMWrapper); |
447 visitor->trace(m_childRuleCSSOMWrappers); | 437 visitor->trace(m_childRuleCSSOMWrappers); |
448 visitor->trace(m_ruleListCSSOMWrapper); | 438 visitor->trace(m_ruleListCSSOMWrapper); |
449 StyleSheet::trace(visitor); | 439 StyleSheet::trace(visitor); |
450 } | 440 } |
451 | 441 |
452 } // namespace blink | 442 } // namespace blink |
OLD | NEW |