| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 nonCharsetRules->rules().append(rule); | 253 nonCharsetRules->rules().append(rule); |
| 254 } | 254 } |
| 255 return nonCharsetRules.release(); | 255 return nonCharsetRules.release(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
eptionState& exceptionState) | 258 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
eptionState& exceptionState) |
| 259 { | 259 { |
| 260 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 260 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 261 | 261 |
| 262 if (index > length()) { | 262 if (index > length()) { |
| 263 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); | 263 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length()) + ")."); |
| 264 return 0; | 264 return 0; |
| 265 } | 265 } |
| 266 BisonCSSParser p(m_contents->parserContext(), UseCounter::getFrom(this)); | 266 BisonCSSParser p(m_contents->parserContext(), UseCounter::getFrom(this)); |
| 267 RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString); | 267 RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString); |
| 268 | 268 |
| 269 if (!rule) { | 269 if (!rule) { |
| 270 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); | 270 exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule
'" + ruleString + "'."); |
| 271 return 0; | 271 return 0; |
| 272 } | 272 } |
| 273 RuleMutationScope mutationScope(this); | 273 RuleMutationScope mutationScope(this); |
| 274 | 274 |
| 275 bool success = m_contents->wrapperInsertRule(rule, index); | 275 bool success = m_contents->wrapperInsertRule(rule, index); |
| 276 if (!success) { | 276 if (!success) { |
| 277 exceptionState.throwUninformativeAndGenericDOMException(HierarchyRequest
Error); | 277 exceptionState.throwDOMException(HierarchyRequestError, "Failed to inser
t the rule."); |
| 278 return 0; | 278 return 0; |
| 279 } | 279 } |
| 280 if (!m_childRuleCSSOMWrappers.isEmpty()) | 280 if (!m_childRuleCSSOMWrappers.isEmpty()) |
| 281 m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); | 281 m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); |
| 282 | 282 |
| 283 return index; | 283 return index; |
| 284 } | 284 } |
| 285 | 285 |
| 286 unsigned CSSStyleSheet::insertRule(const String& rule, ExceptionState& exception
State) | 286 unsigned CSSStyleSheet::insertRule(const String& rule, ExceptionState& exception
State) |
| 287 { | 287 { |
| 288 UseCounter::countDeprecation(activeExecutionContext(), UseCounter::CSSStyleS
heetInsertRuleOptionalArg); | 288 UseCounter::countDeprecation(activeExecutionContext(), UseCounter::CSSStyleS
heetInsertRuleOptionalArg); |
| 289 return insertRule(rule, 0, exceptionState); | 289 return insertRule(rule, 0, exceptionState); |
| 290 } | 290 } |
| 291 | 291 |
| 292 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& exceptionState) | 292 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& exceptionState) |
| 293 { | 293 { |
| 294 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 294 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 295 | 295 |
| 296 if (index >= length()) { | 296 if (index >= length()) { |
| 297 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); | 297 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length() - 1) + ")."); |
| 298 return; | 298 return; |
| 299 } | 299 } |
| 300 RuleMutationScope mutationScope(this); | 300 RuleMutationScope mutationScope(this); |
| 301 | 301 |
| 302 m_contents->wrapperDeleteRule(index); | 302 m_contents->wrapperDeleteRule(index); |
| 303 | 303 |
| 304 if (!m_childRuleCSSOMWrappers.isEmpty()) { | 304 if (!m_childRuleCSSOMWrappers.isEmpty()) { |
| 305 if (m_childRuleCSSOMWrappers[index]) | 305 if (m_childRuleCSSOMWrappers[index]) |
| 306 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); | 306 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); |
| 307 m_childRuleCSSOMWrappers.remove(index); | 307 m_childRuleCSSOMWrappers.remove(index); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 root = root->parentStyleSheet(); | 375 root = root->parentStyleSheet(); |
| 376 return root->ownerNode() ? &root->ownerNode()->document() : 0; | 376 return root->ownerNode() ? &root->ownerNode()->document() : 0; |
| 377 } | 377 } |
| 378 | 378 |
| 379 void CSSStyleSheet::clearChildRuleCSSOMWrappers() | 379 void CSSStyleSheet::clearChildRuleCSSOMWrappers() |
| 380 { | 380 { |
| 381 m_childRuleCSSOMWrappers.clear(); | 381 m_childRuleCSSOMWrappers.clear(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 } | 384 } |
| OLD | NEW |