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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 CSSStyleSheet* parent) | 44 CSSStyleSheet* parent) |
45 : CSSRule(parent), | 45 : CSSRule(parent), |
46 m_groupRule(groupRule), | 46 m_groupRule(groupRule), |
47 m_childRuleCSSOMWrappers(groupRule->childRules().size()) {} | 47 m_childRuleCSSOMWrappers(groupRule->childRules().size()) {} |
48 | 48 |
49 CSSGroupingRule::~CSSGroupingRule() {} | 49 CSSGroupingRule::~CSSGroupingRule() {} |
50 | 50 |
51 unsigned CSSGroupingRule::insertRule(const String& ruleString, | 51 unsigned CSSGroupingRule::insertRule(const String& ruleString, |
52 unsigned index, | 52 unsigned index, |
53 ExceptionState& exceptionState) { | 53 ExceptionState& exceptionState) { |
54 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); | 54 DCHECK_EQ(m_childRuleCSSOMWrappers.size(), m_groupRule->childRules().size()); |
55 | 55 |
56 if (index > m_groupRule->childRules().size()) { | 56 if (index > m_groupRule->childRules().size()) { |
57 exceptionState.throwDOMException( | 57 exceptionState.throwDOMException( |
58 IndexSizeError, | 58 IndexSizeError, |
59 "the index " + String::number(index) + | 59 "the index " + String::number(index) + |
60 " must be less than or equal to the length of the rule list."); | 60 " must be less than or equal to the length of the rule list."); |
61 return 0; | 61 return 0; |
62 } | 62 } |
63 | 63 |
64 CSSStyleSheet* styleSheet = parentStyleSheet(); | 64 CSSStyleSheet* styleSheet = parentStyleSheet(); |
(...skipping 27 matching lines...) Expand all Loading... |
92 CSSStyleSheet::RuleMutationScope mutationScope(this); | 92 CSSStyleSheet::RuleMutationScope mutationScope(this); |
93 | 93 |
94 m_groupRule->wrapperInsertRule(index, newRule); | 94 m_groupRule->wrapperInsertRule(index, newRule); |
95 | 95 |
96 m_childRuleCSSOMWrappers.insert(index, Member<CSSRule>(nullptr)); | 96 m_childRuleCSSOMWrappers.insert(index, Member<CSSRule>(nullptr)); |
97 return index; | 97 return index; |
98 } | 98 } |
99 | 99 |
100 void CSSGroupingRule::deleteRule(unsigned index, | 100 void CSSGroupingRule::deleteRule(unsigned index, |
101 ExceptionState& exceptionState) { | 101 ExceptionState& exceptionState) { |
102 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); | 102 DCHECK_EQ(m_childRuleCSSOMWrappers.size(), m_groupRule->childRules().size()); |
103 | 103 |
104 if (index >= m_groupRule->childRules().size()) { | 104 if (index >= m_groupRule->childRules().size()) { |
105 exceptionState.throwDOMException( | 105 exceptionState.throwDOMException( |
106 IndexSizeError, "the index " + String::number(index) + | 106 IndexSizeError, "the index " + String::number(index) + |
107 " is greated than the length of the rule list."); | 107 " is greated than the length of the rule list."); |
108 return; | 108 return; |
109 } | 109 } |
110 | 110 |
111 CSSStyleSheet::RuleMutationScope mutationScope(this); | 111 CSSStyleSheet::RuleMutationScope mutationScope(this); |
112 | 112 |
(...skipping 13 matching lines...) Expand all Loading... |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 unsigned CSSGroupingRule::length() const { | 129 unsigned CSSGroupingRule::length() const { |
130 return m_groupRule->childRules().size(); | 130 return m_groupRule->childRules().size(); |
131 } | 131 } |
132 | 132 |
133 CSSRule* CSSGroupingRule::item(unsigned index) const { | 133 CSSRule* CSSGroupingRule::item(unsigned index) const { |
134 if (index >= length()) | 134 if (index >= length()) |
135 return nullptr; | 135 return nullptr; |
136 ASSERT(m_childRuleCSSOMWrappers.size() == m_groupRule->childRules().size()); | 136 DCHECK_EQ(m_childRuleCSSOMWrappers.size(), m_groupRule->childRules().size()); |
137 Member<CSSRule>& rule = m_childRuleCSSOMWrappers[index]; | 137 Member<CSSRule>& rule = m_childRuleCSSOMWrappers[index]; |
138 if (!rule) | 138 if (!rule) |
139 rule = m_groupRule->childRules()[index]->createCSSOMWrapper( | 139 rule = m_groupRule->childRules()[index]->createCSSOMWrapper( |
140 const_cast<CSSGroupingRule*>(this)); | 140 const_cast<CSSGroupingRule*>(this)); |
141 return rule.get(); | 141 return rule.get(); |
142 } | 142 } |
143 | 143 |
144 CSSRuleList* CSSGroupingRule::cssRules() const { | 144 CSSRuleList* CSSGroupingRule::cssRules() const { |
145 if (!m_ruleListCSSOMWrapper) | 145 if (!m_ruleListCSSOMWrapper) |
146 m_ruleListCSSOMWrapper = LiveCSSRuleList<CSSGroupingRule>::create( | 146 m_ruleListCSSOMWrapper = LiveCSSRuleList<CSSGroupingRule>::create( |
147 const_cast<CSSGroupingRule*>(this)); | 147 const_cast<CSSGroupingRule*>(this)); |
148 return m_ruleListCSSOMWrapper.get(); | 148 return m_ruleListCSSOMWrapper.get(); |
149 } | 149 } |
150 | 150 |
151 void CSSGroupingRule::reattach(StyleRuleBase* rule) { | 151 void CSSGroupingRule::reattach(StyleRuleBase* rule) { |
152 ASSERT(rule); | 152 DCHECK(rule); |
153 m_groupRule = static_cast<StyleRuleGroup*>(rule); | 153 m_groupRule = static_cast<StyleRuleGroup*>(rule); |
154 for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) { | 154 for (unsigned i = 0; i < m_childRuleCSSOMWrappers.size(); ++i) { |
155 if (m_childRuleCSSOMWrappers[i]) | 155 if (m_childRuleCSSOMWrappers[i]) |
156 m_childRuleCSSOMWrappers[i]->reattach(m_groupRule->childRules()[i].get()); | 156 m_childRuleCSSOMWrappers[i]->reattach(m_groupRule->childRules()[i].get()); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 DEFINE_TRACE(CSSGroupingRule) { | 160 DEFINE_TRACE(CSSGroupingRule) { |
161 CSSRule::trace(visitor); | 161 CSSRule::trace(visitor); |
162 visitor->trace(m_childRuleCSSOMWrappers); | 162 visitor->trace(m_childRuleCSSOMWrappers); |
163 visitor->trace(m_groupRule); | 163 visitor->trace(m_groupRule); |
164 visitor->trace(m_ruleListCSSOMWrapper); | 164 visitor->trace(m_ruleListCSSOMWrapper); |
165 } | 165 } |
166 | 166 |
167 } // namespace blink | 167 } // namespace blink |
OLD | NEW |