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 17 matching lines...) Expand all Loading... |
28 * SUCH DAMAGE. | 28 * SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/css/CSSGroupingRule.h" | 32 #include "core/css/CSSGroupingRule.h" |
33 | 33 |
34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
35 #include "core/css/CSSRuleList.h" | 35 #include "core/css/CSSRuleList.h" |
36 #include "core/css/CSSStyleSheet.h" | 36 #include "core/css/CSSStyleSheet.h" |
37 #include "core/css/parser/CSSParser.h" | 37 #include "core/css/parser/CSSParser.h" |
38 #include "core/dom/Document.h" | |
39 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
40 #include "core/frame/UseCounter.h" | 39 #include "core/frame/UseCounter.h" |
41 #include "wtf/text/StringBuilder.h" | 40 #include "wtf/text/StringBuilder.h" |
42 | 41 |
43 namespace blink { | 42 namespace blink { |
44 | 43 |
45 CSSGroupingRule::CSSGroupingRule(StyleRuleGroup* groupRule, CSSStyleSheet* paren
t) | 44 CSSGroupingRule::CSSGroupingRule(StyleRuleGroup* groupRule, CSSStyleSheet* paren
t) |
46 : CSSRule(parent) | 45 : CSSRule(parent) |
47 , m_groupRule(groupRule) | 46 , m_groupRule(groupRule) |
48 , m_childRuleCSSOMWrappers(groupRule->childRules().size()) | 47 , m_childRuleCSSOMWrappers(groupRule->childRules().size()) |
(...skipping 14 matching lines...) Expand all Loading... |
63 unsigned CSSGroupingRule::insertRule(const String& ruleString, unsigned index, E
xceptionState& exceptionState) | 62 unsigned CSSGroupingRule::insertRule(const String& ruleString, unsigned index, E
xceptionState& exceptionState) |
64 { | 63 { |
65 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); | 64 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); |
66 | 65 |
67 if (index > m_groupRule->childRules().size()) { | 66 if (index > m_groupRule->childRules().size()) { |
68 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."); |
69 return 0; | 68 return 0; |
70 } | 69 } |
71 | 70 |
72 CSSStyleSheet* styleSheet = parentStyleSheet(); | 71 CSSStyleSheet* styleSheet = parentStyleSheet(); |
73 Document* doc = styleSheet ? styleSheet->ownerDocument() : 0; | 72 CSSParserContext context(parserContext(), UseCounter::getFrom(styleSheet)); |
74 CSSParserContext context(parserContext(), doc ? doc->frame() : 0, UseCounter
::getFrom(styleSheet)); | |
75 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); |
76 // FIXME: @namespace rules have special handling in the CSSOM spec, but it | 74 // FIXME: @namespace rules have special handling in the CSSOM spec, but it |
77 // mostly doesn't make sense since we don't support CSSNamespaceRule | 75 // mostly doesn't make sense since we don't support CSSNamespaceRule |
78 if (!newRule || newRule->isNamespaceRule()) { | 76 if (!newRule || newRule->isNamespaceRule()) { |
79 exceptionState.throwDOMException(SyntaxError, "the rule '" + ruleString
+ "' is invalid and cannot be parsed."); | 77 exceptionState.throwDOMException(SyntaxError, "the rule '" + ruleString
+ "' is invalid and cannot be parsed."); |
80 return 0; | 78 return 0; |
81 } | 79 } |
82 | 80 |
83 if (newRule->isImportRule()) { | 81 if (newRule->isImportRule()) { |
84 // FIXME: an HierarchyRequestError should also be thrown for a nested @m
edia rule. They are | 82 // FIXME: an HierarchyRequestError should also be thrown for a nested @m
edia rule. They are |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 { | 157 { |
160 CSSRule::trace(visitor); | 158 CSSRule::trace(visitor); |
161 #if ENABLE(OILPAN) | 159 #if ENABLE(OILPAN) |
162 visitor->trace(m_childRuleCSSOMWrappers); | 160 visitor->trace(m_childRuleCSSOMWrappers); |
163 #endif | 161 #endif |
164 visitor->trace(m_groupRule); | 162 visitor->trace(m_groupRule); |
165 visitor->trace(m_ruleListCSSOMWrapper); | 163 visitor->trace(m_ruleListCSSOMWrapper); |
166 } | 164 } |
167 | 165 |
168 } // namespace blink | 166 } // namespace blink |
OLD | NEW |