| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return 0; | 327 return 0; |
| 328 } | 328 } |
| 329 if (!m_childRuleCSSOMWrappers.isEmpty()) | 329 if (!m_childRuleCSSOMWrappers.isEmpty()) |
| 330 m_childRuleCSSOMWrappers.insert(index, RefPtrWillBeMember<CSSRule>(nullp
tr)); | 330 m_childRuleCSSOMWrappers.insert(index, RefPtrWillBeMember<CSSRule>(nullp
tr)); |
| 331 | 331 |
| 332 return index; | 332 return index; |
| 333 } | 333 } |
| 334 | 334 |
| 335 unsigned CSSStyleSheet::insertRule(const String& rule, ExceptionState& exception
State) | 335 unsigned CSSStyleSheet::insertRule(const String& rule, ExceptionState& exception
State) |
| 336 { | 336 { |
| 337 UseCounter::countDeprecation(callingExecutionContext(V8PerIsolateData::mainT
hreadIsolate()), UseCounter::CSSStyleSheetInsertRuleOptionalArg); | |
| 338 return insertRule(rule, 0, exceptionState); | 337 return insertRule(rule, 0, exceptionState); |
| 339 } | 338 } |
| 340 | 339 |
| 341 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& exceptionState) | 340 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& exceptionState) |
| 342 { | 341 { |
| 343 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 342 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 344 | 343 |
| 345 if (index >= length()) { | 344 if (index >= length()) { |
| 346 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length() - 1) + ")."); | 345 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length() - 1) + ")."); |
| 347 return; | 346 return; |
| 348 } | 347 } |
| 349 RuleMutationScope mutationScope(this); | 348 RuleMutationScope mutationScope(this); |
| 350 | 349 |
| 351 m_contents->wrapperDeleteRule(index); | 350 m_contents->wrapperDeleteRule(index); |
| 352 | 351 |
| 353 if (!m_childRuleCSSOMWrappers.isEmpty()) { | 352 if (!m_childRuleCSSOMWrappers.isEmpty()) { |
| 354 if (m_childRuleCSSOMWrappers[index]) | 353 if (m_childRuleCSSOMWrappers[index]) |
| 355 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); | 354 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); |
| 356 m_childRuleCSSOMWrappers.remove(index); | 355 m_childRuleCSSOMWrappers.remove(index); |
| 357 } | 356 } |
| 358 } | 357 } |
| 359 | 358 |
| 360 int CSSStyleSheet::addRule(const String& selector, const String& style, int inde
x, ExceptionState& exceptionState) | 359 int CSSStyleSheet::addRule(const String& selector, const String& style, Optional
<int> index, ExceptionState& exceptionState) |
| 361 { | 360 { |
| 362 StringBuilder text; | 361 StringBuilder text; |
| 363 text.append(selector); | 362 text.append(selector); |
| 364 text.appendLiteral(" { "); | 363 text.appendLiteral(" { "); |
| 365 text.append(style); | 364 text.append(style); |
| 366 if (!style.isEmpty()) | 365 if (!style.isEmpty()) |
| 367 text.append(' '); | 366 text.append(' '); |
| 368 text.append('}'); | 367 text.append('}'); |
| 369 insertRule(text.toString(), index, exceptionState); | 368 insertRule(text.toString(), index.isMissing() ? length() : index.get(), exce
ptionState); |
| 370 | 369 |
| 371 // As per Microsoft documentation, always return -1. | 370 // As per Microsoft documentation, always return -1. |
| 372 return -1; | 371 return -1; |
| 373 } | 372 } |
| 374 | 373 |
| 375 int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio
nState& exceptionState) | |
| 376 { | |
| 377 return addRule(selector, style, length(), exceptionState); | |
| 378 } | |
| 379 | |
| 380 | 374 |
| 381 PassRefPtrWillBeRawPtr<CSSRuleList> CSSStyleSheet::cssRules() | 375 PassRefPtrWillBeRawPtr<CSSRuleList> CSSStyleSheet::cssRules() |
| 382 { | 376 { |
| 383 if (!canAccessRules()) | 377 if (!canAccessRules()) |
| 384 return nullptr; | 378 return nullptr; |
| 385 if (!m_ruleListCSSOMWrapper) | 379 if (!m_ruleListCSSOMWrapper) |
| 386 m_ruleListCSSOMWrapper = StyleSheetCSSRuleList::create(this); | 380 m_ruleListCSSOMWrapper = StyleSheetCSSRuleList::create(this); |
| 387 return m_ruleListCSSOMWrapper.get(); | 381 return m_ruleListCSSOMWrapper.get(); |
| 388 } | 382 } |
| 389 | 383 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 visitor->trace(m_mediaQueries); | 456 visitor->trace(m_mediaQueries); |
| 463 visitor->trace(m_ownerNode); | 457 visitor->trace(m_ownerNode); |
| 464 visitor->trace(m_ownerRule); | 458 visitor->trace(m_ownerRule); |
| 465 visitor->trace(m_mediaCSSOMWrapper); | 459 visitor->trace(m_mediaCSSOMWrapper); |
| 466 visitor->trace(m_childRuleCSSOMWrappers); | 460 visitor->trace(m_childRuleCSSOMWrappers); |
| 467 visitor->trace(m_ruleListCSSOMWrapper); | 461 visitor->trace(m_ruleListCSSOMWrapper); |
| 468 StyleSheet::trace(visitor); | 462 StyleSheet::trace(visitor); |
| 469 } | 463 } |
| 470 | 464 |
| 471 } | 465 } |
| OLD | NEW |