| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 { | 285 { |
| 286 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 286 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 287 | 287 |
| 288 if (index > length()) { | 288 if (index > length()) { |
| 289 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length()) + ")."); | 289 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length()) + ")."); |
| 290 return 0; | 290 return 0; |
| 291 } | 291 } |
| 292 CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(th
is)); | 292 CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(th
is)); |
| 293 RefPtrWillBeRawPtr<StyleRuleBase> rule = CSSParser::parseRule(context, m_con
tents.get(), ruleString); | 293 RefPtrWillBeRawPtr<StyleRuleBase> rule = CSSParser::parseRule(context, m_con
tents.get(), ruleString); |
| 294 | 294 |
| 295 // FIXME: @namespace rules have special handling in the CSSOM spec, but it | 295 if (!rule) { |
| 296 // mostly doesn't make sense since we don't support CSSNamespaceRule | |
| 297 if (!rule || rule->isNamespaceRule()) { | |
| 298 exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule
'" + ruleString + "'."); | 296 exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule
'" + ruleString + "'."); |
| 299 return 0; | 297 return 0; |
| 300 } | 298 } |
| 301 RuleMutationScope mutationScope(this); | 299 RuleMutationScope mutationScope(this); |
| 302 | 300 |
| 303 bool success = m_contents->wrapperInsertRule(rule, index); | 301 bool success = m_contents->wrapperInsertRule(rule, index); |
| 304 if (!success) { | 302 if (!success) { |
| 305 exceptionState.throwDOMException(HierarchyRequestError, "Failed to inser
t the rule."); | 303 if (rule->isNamespaceRule()) |
| 304 exceptionState.throwDOMException(InvalidStateError, "Failed to inser
t the rule"); |
| 305 else |
| 306 exceptionState.throwDOMException(HierarchyRequestError, "Failed to i
nsert the rule."); |
| 306 return 0; | 307 return 0; |
| 307 } | 308 } |
| 308 if (!m_childRuleCSSOMWrappers.isEmpty()) | 309 if (!m_childRuleCSSOMWrappers.isEmpty()) |
| 309 m_childRuleCSSOMWrappers.insert(index, RefPtrWillBeMember<CSSRule>(nullp
tr)); | 310 m_childRuleCSSOMWrappers.insert(index, RefPtrWillBeMember<CSSRule>(nullp
tr)); |
| 310 | 311 |
| 311 return index; | 312 return index; |
| 312 } | 313 } |
| 313 | 314 |
| 314 unsigned CSSStyleSheet::insertRule(const String& rule, ExceptionState& exception
State) | 315 unsigned CSSStyleSheet::insertRule(const String& rule, ExceptionState& exception
State) |
| 315 { | 316 { |
| 316 UseCounter::countDeprecation(callingExecutionContext(V8PerIsolateData::mainT
hreadIsolate()), UseCounter::CSSStyleSheetInsertRuleOptionalArg); | 317 UseCounter::countDeprecation(callingExecutionContext(V8PerIsolateData::mainT
hreadIsolate()), UseCounter::CSSStyleSheetInsertRuleOptionalArg); |
| 317 return insertRule(rule, 0, exceptionState); | 318 return insertRule(rule, 0, exceptionState); |
| 318 } | 319 } |
| 319 | 320 |
| 320 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& exceptionState) | 321 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& exceptionState) |
| 321 { | 322 { |
| 322 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 323 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 323 | 324 |
| 324 if (index >= length()) { | 325 if (index >= length()) { |
| 325 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length() - 1) + ")."); | 326 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length() - 1) + ")."); |
| 326 return; | 327 return; |
| 327 } | 328 } |
| 328 RuleMutationScope mutationScope(this); | 329 RuleMutationScope mutationScope(this); |
| 329 | 330 |
| 330 m_contents->wrapperDeleteRule(index); | 331 bool success = m_contents->wrapperDeleteRule(index); |
| 332 if (!success) { |
| 333 exceptionState.throwDOMException(InvalidStateError, "Failed to delete ru
le"); |
| 334 return; |
| 335 } |
| 331 | 336 |
| 332 if (!m_childRuleCSSOMWrappers.isEmpty()) { | 337 if (!m_childRuleCSSOMWrappers.isEmpty()) { |
| 333 if (m_childRuleCSSOMWrappers[index]) | 338 if (m_childRuleCSSOMWrappers[index]) |
| 334 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); | 339 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); |
| 335 m_childRuleCSSOMWrappers.remove(index); | 340 m_childRuleCSSOMWrappers.remove(index); |
| 336 } | 341 } |
| 337 } | 342 } |
| 338 | 343 |
| 339 int CSSStyleSheet::addRule(const String& selector, const String& style, int inde
x, ExceptionState& exceptionState) | 344 int CSSStyleSheet::addRule(const String& selector, const String& style, int inde
x, ExceptionState& exceptionState) |
| 340 { | 345 { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 visitor->trace(m_mediaQueries); | 451 visitor->trace(m_mediaQueries); |
| 447 visitor->trace(m_ownerNode); | 452 visitor->trace(m_ownerNode); |
| 448 visitor->trace(m_ownerRule); | 453 visitor->trace(m_ownerRule); |
| 449 visitor->trace(m_mediaCSSOMWrapper); | 454 visitor->trace(m_mediaCSSOMWrapper); |
| 450 visitor->trace(m_childRuleCSSOMWrappers); | 455 visitor->trace(m_childRuleCSSOMWrappers); |
| 451 visitor->trace(m_ruleListCSSOMWrapper); | 456 visitor->trace(m_ruleListCSSOMWrapper); |
| 452 StyleSheet::trace(visitor); | 457 StyleSheet::trace(visitor); |
| 453 } | 458 } |
| 454 | 459 |
| 455 } // namespace blink | 460 } // namespace blink |
| OLD | NEW |