| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
| 3 * Copyright (C) 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above | 9 * 1. Redistributions of source code must retain the above |
| 10 * copyright notice, this list of conditions and the following | 10 * copyright notice, this list of conditions and the following |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 CSSGroupingRule::~CSSGroupingRule() | 52 CSSGroupingRule::~CSSGroupingRule() |
| 53 { | 53 { |
| 54 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); | 54 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); |
| 55 for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) { | 55 for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) { |
| 56 if (m_childRuleCSSOMWrappers[i]) | 56 if (m_childRuleCSSOMWrappers[i]) |
| 57 m_childRuleCSSOMWrappers[i]->setParentRule(0); | 57 m_childRuleCSSOMWrappers[i]->setParentRule(0); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 unsigned CSSGroupingRule::insertRule(const String& ruleString, unsigned index, E
xceptionState& es) | 61 unsigned CSSGroupingRule::insertRule(const String& ruleString, unsigned index, E
xceptionState& exceptionState) |
| 62 { | 62 { |
| 63 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); | 63 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); |
| 64 | 64 |
| 65 if (index > m_groupRule->childRules().size()) { | 65 if (index > m_groupRule->childRules().size()) { |
| 66 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"insertRule", "CSSGroupingRule", "the index " + String::number(index) + " must b
e less than or equal to the length of the rule list.")); | 66 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToExecute("insertRule", "CSSGroupingRule", "the index " + String::number(index
) + " must be less than or equal to the length of the rule list.")); |
| 67 return 0; | 67 return 0; |
| 68 } | 68 } |
| 69 | 69 |
| 70 CSSStyleSheet* styleSheet = parentStyleSheet(); | 70 CSSStyleSheet* styleSheet = parentStyleSheet(); |
| 71 CSSParser parser(parserContext(), UseCounter::getFrom(styleSheet)); | 71 CSSParser parser(parserContext(), UseCounter::getFrom(styleSheet)); |
| 72 RefPtr<StyleRuleBase> newRule = parser.parseRule(styleSheet ? styleSheet->co
ntents() : 0, ruleString); | 72 RefPtr<StyleRuleBase> newRule = parser.parseRule(styleSheet ? styleSheet->co
ntents() : 0, ruleString); |
| 73 if (!newRule) { | 73 if (!newRule) { |
| 74 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("in
sertRule", "CSSGroupingRule", "the rule '" + ruleString + "' is invalid and cann
ot be parsed.")); | 74 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT
oExecute("insertRule", "CSSGroupingRule", "the rule '" + ruleString + "' is inva
lid and cannot be parsed.")); |
| 75 return 0; | 75 return 0; |
| 76 } | 76 } |
| 77 | 77 |
| 78 if (newRule->isImportRule()) { | 78 if (newRule->isImportRule()) { |
| 79 // FIXME: an HierarchyRequestError should also be thrown for a @charset
or a nested | 79 // FIXME: an HierarchyRequestError should also be thrown for a @charset
or a nested |
| 80 // @media rule. They are currently not getting parsed, resulting in a Sy
ntaxError | 80 // @media rule. They are currently not getting parsed, resulting in a Sy
ntaxError |
| 81 // to get raised above. | 81 // to get raised above. |
| 82 es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToE
xecute("insertRule", "CSSGroupingRule", "'@import' rules cannot be inserted insi
de a group rule.")); | 82 exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessage
s::failedToExecute("insertRule", "CSSGroupingRule", "'@import' rules cannot be i
nserted inside a group rule.")); |
| 83 return 0; | 83 return 0; |
| 84 } | 84 } |
| 85 CSSStyleSheet::RuleMutationScope mutationScope(this); | 85 CSSStyleSheet::RuleMutationScope mutationScope(this); |
| 86 | 86 |
| 87 m_groupRule->wrapperInsertRule(index, newRule); | 87 m_groupRule->wrapperInsertRule(index, newRule); |
| 88 | 88 |
| 89 m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); | 89 m_childRuleCSSOMWrappers.insert(index, RefPtr<CSSRule>()); |
| 90 return index; | 90 return index; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void CSSGroupingRule::deleteRule(unsigned index, ExceptionState& es) | 93 void CSSGroupingRule::deleteRule(unsigned index, ExceptionState& exceptionState) |
| 94 { | 94 { |
| 95 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); | 95 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); |
| 96 | 96 |
| 97 if (index >= m_groupRule->childRules().size()) { | 97 if (index >= m_groupRule->childRules().size()) { |
| 98 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"deleteRule", "CSSGroupingRule", "the index " + String::number(index) + " is gre
ated than the length of the rule list.")); | 98 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::fail
edToExecute("deleteRule", "CSSGroupingRule", "the index " + String::number(index
) + " is greated than the length of the rule list.")); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 CSSStyleSheet::RuleMutationScope mutationScope(this); | 102 CSSStyleSheet::RuleMutationScope mutationScope(this); |
| 103 | 103 |
| 104 m_groupRule->wrapperRemoveRule(index); | 104 m_groupRule->wrapperRemoveRule(index); |
| 105 | 105 |
| 106 if (m_childRuleCSSOMWrappers[index]) | 106 if (m_childRuleCSSOMWrappers[index]) |
| 107 m_childRuleCSSOMWrappers[index]->setParentRule(0); | 107 m_childRuleCSSOMWrappers[index]->setParentRule(0); |
| 108 m_childRuleCSSOMWrappers.remove(index); | 108 m_childRuleCSSOMWrappers.remove(index); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 { | 145 { |
| 146 ASSERT(rule); | 146 ASSERT(rule); |
| 147 m_groupRule = static_cast<StyleRuleGroup*>(rule); | 147 m_groupRule = static_cast<StyleRuleGroup*>(rule); |
| 148 for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) { | 148 for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) { |
| 149 if (m_childRuleCSSOMWrappers[i]) | 149 if (m_childRuleCSSOMWrappers[i]) |
| 150 m_childRuleCSSOMWrappers[i]->reattach(m_groupRule->childRules()[i].g
et()); | 150 m_childRuleCSSOMWrappers[i]->reattach(m_groupRule->childRules()[i].g
et()); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace WebCore | 154 } // namespace WebCore |
| OLD | NEW |