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