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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); | 64 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); |
65 | 65 |
66 if (index > m_groupRule->childRules().size()) { | 66 if (index > m_groupRule->childRules().size()) { |
67 exceptionState.throwDOMException(IndexSizeError, "the index " + String::
number(index) + " must be less than or equal to the length of the rule list."); | 67 exceptionState.throwDOMException(IndexSizeError, "the index " + String::
number(index) + " must be less than or equal to the length of the rule list."); |
68 return 0; | 68 return 0; |
69 } | 69 } |
70 | 70 |
71 CSSStyleSheet* styleSheet = parentStyleSheet(); | 71 CSSStyleSheet* styleSheet = parentStyleSheet(); |
72 CSSParserContext context(parserContext(), UseCounter::getFrom(styleSheet)); | 72 CSSParserContext context(parserContext(), UseCounter::getFrom(styleSheet)); |
73 RefPtrWillBeRawPtr<StyleRuleBase> newRule = CSSParser::parseRule(context, st
yleSheet ? styleSheet->contents() : nullptr, ruleString); | 73 RefPtrWillBeRawPtr<StyleRuleBase> newRule = CSSParser::parseRule(context, st
yleSheet ? styleSheet->contents() : nullptr, ruleString); |
74 // FIXME: @namespace rules have special handling in the CSSOM spec, but it | 74 if (!newRule) { |
75 // mostly doesn't make sense since we don't support CSSNamespaceRule | |
76 if (!newRule || newRule->isNamespaceRule()) { | |
77 exceptionState.throwDOMException(SyntaxError, "the rule '" + ruleString
+ "' is invalid and cannot be parsed."); | 75 exceptionState.throwDOMException(SyntaxError, "the rule '" + ruleString
+ "' is invalid and cannot be parsed."); |
78 return 0; | 76 return 0; |
79 } | 77 } |
80 | 78 |
| 79 if (newRule->isNamespaceRule()) { |
| 80 exceptionState.throwDOMException(HierarchyRequestError, "'@namespace' ru
les cannot be inserted inside a group rule."); |
| 81 return 0; |
| 82 } |
| 83 |
81 if (newRule->isImportRule()) { | 84 if (newRule->isImportRule()) { |
82 // FIXME: an HierarchyRequestError should also be thrown for a nested @m
edia rule. They are | 85 // FIXME: an HierarchyRequestError should also be thrown for a nested @m
edia rule. They are |
83 // currently not getting parsed, resulting in a SyntaxError to get raise
d above. | 86 // currently not getting parsed, resulting in a SyntaxError to get raise
d above. |
84 exceptionState.throwDOMException(HierarchyRequestError, "'@import' rules
cannot be inserted inside a group rule."); | 87 exceptionState.throwDOMException(HierarchyRequestError, "'@import' rules
cannot be inserted inside a group rule."); |
85 return 0; | 88 return 0; |
86 } | 89 } |
87 CSSStyleSheet::RuleMutationScope mutationScope(this); | 90 CSSStyleSheet::RuleMutationScope mutationScope(this); |
88 | 91 |
89 m_groupRule->wrapperInsertRule(index, newRule); | 92 m_groupRule->wrapperInsertRule(index, newRule); |
90 | 93 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 { | 160 { |
158 CSSRule::trace(visitor); | 161 CSSRule::trace(visitor); |
159 #if ENABLE(OILPAN) | 162 #if ENABLE(OILPAN) |
160 visitor->trace(m_childRuleCSSOMWrappers); | 163 visitor->trace(m_childRuleCSSOMWrappers); |
161 #endif | 164 #endif |
162 visitor->trace(m_groupRule); | 165 visitor->trace(m_groupRule); |
163 visitor->trace(m_ruleListCSSOMWrapper); | 166 visitor->trace(m_ruleListCSSOMWrapper); |
164 } | 167 } |
165 | 168 |
166 } // namespace blink | 169 } // namespace blink |
OLD | NEW |