| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 nonCharsetRules->rules().append(rule); | 243 nonCharsetRules->rules().append(rule); |
| 244 } | 244 } |
| 245 return nonCharsetRules.release(); | 245 return nonCharsetRules.release(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
eptionState& es) | 248 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
eptionState& es) |
| 249 { | 249 { |
| 250 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 250 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 251 | 251 |
| 252 if (index > length()) { | 252 if (index > length()) { |
| 253 es.throwDOMException(IndexSizeError); | 253 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 254 return 0; | 254 return 0; |
| 255 } | 255 } |
| 256 CSSParser p(m_contents->parserContext(), UseCounter::getFrom(this)); | 256 CSSParser p(m_contents->parserContext(), UseCounter::getFrom(this)); |
| 257 RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString); | 257 RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString); |
| 258 | 258 |
| 259 if (!rule) { | 259 if (!rule) { |
| 260 es.throwDOMException(SyntaxError); | 260 es.throwUninformativeAndGenericDOMException(SyntaxError); |
| 261 return 0; | 261 return 0; |
| 262 } | 262 } |
| 263 RuleMutationScope mutationScope(this); | 263 RuleMutationScope mutationScope(this); |
| 264 | 264 |
| 265 bool success = m_contents->wrapperInsertRule(rule, index); | 265 bool success = m_contents->wrapperInsertRule(rule, index); |
| 266 if (!success) { | 266 if (!success) { |
| 267 es.throwDOMException(HierarchyRequestError); | 267 es.throwUninformativeAndGenericDOMException(HierarchyRequestError); |
| 268 return 0; | 268 return 0; |
| 269 } | 269 } |
| 270 if (!m_childRuleCSSOMWrappers.isEmpty()) | 270 if (!m_childRuleCSSOMWrappers.isEmpty()) |
| 271 m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); | 271 m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); |
| 272 | 272 |
| 273 return index; | 273 return index; |
| 274 } | 274 } |
| 275 | 275 |
| 276 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& es) | 276 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& es) |
| 277 { | 277 { |
| 278 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 278 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 279 | 279 |
| 280 if (index >= length()) { | 280 if (index >= length()) { |
| 281 es.throwDOMException(IndexSizeError); | 281 es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 282 return; | 282 return; |
| 283 } | 283 } |
| 284 RuleMutationScope mutationScope(this); | 284 RuleMutationScope mutationScope(this); |
| 285 | 285 |
| 286 m_contents->wrapperDeleteRule(index); | 286 m_contents->wrapperDeleteRule(index); |
| 287 | 287 |
| 288 if (!m_childRuleCSSOMWrappers.isEmpty()) { | 288 if (!m_childRuleCSSOMWrappers.isEmpty()) { |
| 289 if (m_childRuleCSSOMWrappers[index]) | 289 if (m_childRuleCSSOMWrappers[index]) |
| 290 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); | 290 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); |
| 291 m_childRuleCSSOMWrappers.remove(index); | 291 m_childRuleCSSOMWrappers.remove(index); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 root = root->parentStyleSheet(); | 359 root = root->parentStyleSheet(); |
| 360 return root->ownerNode() ? &root->ownerNode()->document() : 0; | 360 return root->ownerNode() ? &root->ownerNode()->document() : 0; |
| 361 } | 361 } |
| 362 | 362 |
| 363 void CSSStyleSheet::clearChildRuleCSSOMWrappers() | 363 void CSSStyleSheet::clearChildRuleCSSOMWrappers() |
| 364 { | 364 { |
| 365 m_childRuleCSSOMWrappers.clear(); | 365 m_childRuleCSSOMWrappers.clear(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 } | 368 } |
| OLD | NEW |