| 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 unsigned ruleCount = length(); | 285 unsigned ruleCount = length(); |
| 286 for (unsigned i = 0; i < ruleCount; ++i) { | 286 for (unsigned i = 0; i < ruleCount; ++i) { |
| 287 CSSRule* rule = item(i); | 287 CSSRule* rule = item(i); |
| 288 if (rule->type() == CSSRule::CHARSET_RULE) | 288 if (rule->type() == CSSRule::CHARSET_RULE) |
| 289 continue; | 289 continue; |
| 290 nonCharsetRules->rules().append(rule); | 290 nonCharsetRules->rules().append(rule); |
| 291 } | 291 } |
| 292 return nonCharsetRules.release(); | 292 return nonCharsetRules.release(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
eptionState& es) | 295 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
eptionState& exceptionState) |
| 296 { | 296 { |
| 297 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 297 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 298 | 298 |
| 299 if (index > length()) { | 299 if (index > length()) { |
| 300 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 300 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 301 return 0; | 301 return 0; |
| 302 } | 302 } |
| 303 CSSParser p(m_contents->parserContext(), UseCounter::getFrom(this)); | 303 CSSParser p(m_contents->parserContext(), UseCounter::getFrom(this)); |
| 304 RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString); | 304 RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString); |
| 305 | 305 |
| 306 if (!rule) { | 306 if (!rule) { |
| 307 es.throwUninformativeAndGenericDOMException(SyntaxError); | 307 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); |
| 308 return 0; | 308 return 0; |
| 309 } | 309 } |
| 310 RuleMutationScope mutationScope(this); | 310 RuleMutationScope mutationScope(this); |
| 311 | 311 |
| 312 bool success = m_contents->wrapperInsertRule(rule, index); | 312 bool success = m_contents->wrapperInsertRule(rule, index); |
| 313 if (!success) { | 313 if (!success) { |
| 314 es.throwUninformativeAndGenericDOMException(HierarchyRequestError); | 314 exceptionState.throwUninformativeAndGenericDOMException(HierarchyRequest
Error); |
| 315 return 0; | 315 return 0; |
| 316 } | 316 } |
| 317 if (!m_childRuleCSSOMWrappers.isEmpty()) | 317 if (!m_childRuleCSSOMWrappers.isEmpty()) |
| 318 m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); | 318 m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); |
| 319 | 319 |
| 320 return index; | 320 return index; |
| 321 } | 321 } |
| 322 | 322 |
| 323 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& es) | 323 void CSSStyleSheet::deleteRule(unsigned index, ExceptionState& exceptionState) |
| 324 { | 324 { |
| 325 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 325 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 326 | 326 |
| 327 if (index >= length()) { | 327 if (index >= length()) { |
| 328 es.throwUninformativeAndGenericDOMException(IndexSizeError); | 328 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 329 return; | 329 return; |
| 330 } | 330 } |
| 331 RuleMutationScope mutationScope(this); | 331 RuleMutationScope mutationScope(this); |
| 332 | 332 |
| 333 m_contents->wrapperDeleteRule(index); | 333 m_contents->wrapperDeleteRule(index); |
| 334 | 334 |
| 335 if (!m_childRuleCSSOMWrappers.isEmpty()) { | 335 if (!m_childRuleCSSOMWrappers.isEmpty()) { |
| 336 if (m_childRuleCSSOMWrappers[index]) | 336 if (m_childRuleCSSOMWrappers[index]) |
| 337 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); | 337 m_childRuleCSSOMWrappers[index]->setParentStyleSheet(0); |
| 338 m_childRuleCSSOMWrappers.remove(index); | 338 m_childRuleCSSOMWrappers.remove(index); |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 int CSSStyleSheet::addRule(const String& selector, const String& style, int inde
x, ExceptionState& es) | 342 int CSSStyleSheet::addRule(const String& selector, const String& style, int inde
x, ExceptionState& exceptionState) |
| 343 { | 343 { |
| 344 StringBuilder text; | 344 StringBuilder text; |
| 345 text.append(selector); | 345 text.append(selector); |
| 346 text.appendLiteral(" { "); | 346 text.appendLiteral(" { "); |
| 347 text.append(style); | 347 text.append(style); |
| 348 if (!style.isEmpty()) | 348 if (!style.isEmpty()) |
| 349 text.append(' '); | 349 text.append(' '); |
| 350 text.append('}'); | 350 text.append('}'); |
| 351 insertRule(text.toString(), index, es); | 351 insertRule(text.toString(), index, exceptionState); |
| 352 | 352 |
| 353 // As per Microsoft documentation, always return -1. | 353 // As per Microsoft documentation, always return -1. |
| 354 return -1; | 354 return -1; |
| 355 } | 355 } |
| 356 | 356 |
| 357 int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio
nState& es) | 357 int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio
nState& exceptionState) |
| 358 { | 358 { |
| 359 return addRule(selector, style, length(), es); | 359 return addRule(selector, style, length(), exceptionState); |
| 360 } | 360 } |
| 361 | 361 |
| 362 | 362 |
| 363 PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules() | 363 PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules() |
| 364 { | 364 { |
| 365 if (!canAccessRules()) | 365 if (!canAccessRules()) |
| 366 return 0; | 366 return 0; |
| 367 if (!m_ruleListCSSOMWrapper) | 367 if (!m_ruleListCSSOMWrapper) |
| 368 m_ruleListCSSOMWrapper = adoptPtr(new StyleSheetCSSRuleList(this)); | 368 m_ruleListCSSOMWrapper = adoptPtr(new StyleSheetCSSRuleList(this)); |
| 369 return m_ruleListCSSOMWrapper.get(); | 369 return m_ruleListCSSOMWrapper.get(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 root = root->parentStyleSheet(); | 406 root = root->parentStyleSheet(); |
| 407 return root->ownerNode() ? &root->ownerNode()->document() : 0; | 407 return root->ownerNode() ? &root->ownerNode()->document() : 0; |
| 408 } | 408 } |
| 409 | 409 |
| 410 void CSSStyleSheet::clearChildRuleCSSOMWrappers() | 410 void CSSStyleSheet::clearChildRuleCSSOMWrappers() |
| 411 { | 411 { |
| 412 m_childRuleCSSOMWrappers.clear(); | 412 m_childRuleCSSOMWrappers.clear(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 } | 415 } |
| OLD | NEW |