Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: third_party/WebKit/Source/core/css/CSSKeyframesRule.cpp

Issue 2755493004: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/css/ (Closed)
Patch Set: Worked on Review Comments done Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 CSSKeyframesRule::~CSSKeyframesRule() {} 89 CSSKeyframesRule::~CSSKeyframesRule() {}
90 90
91 void CSSKeyframesRule::setName(const String& name) { 91 void CSSKeyframesRule::setName(const String& name) {
92 CSSStyleSheet::RuleMutationScope mutationScope(this); 92 CSSStyleSheet::RuleMutationScope mutationScope(this);
93 93
94 m_keyframesRule->setName(name); 94 m_keyframesRule->setName(name);
95 } 95 }
96 96
97 void CSSKeyframesRule::appendRule(const String& ruleText) { 97 void CSSKeyframesRule::appendRule(const String& ruleText) {
98 ASSERT(m_childRuleCSSOMWrappers.size() == 98 DCHECK_EQ(m_childRuleCSSOMWrappers.size(),
99 m_keyframesRule->keyframes().size()); 99 m_keyframesRule->keyframes().size());
100 100
101 CSSStyleSheet* styleSheet = parentStyleSheet(); 101 CSSStyleSheet* styleSheet = parentStyleSheet();
102 CSSParserContext* context = 102 CSSParserContext* context =
103 CSSParserContext::createWithStyleSheet(parserContext(), styleSheet); 103 CSSParserContext::createWithStyleSheet(parserContext(), styleSheet);
104 StyleRuleKeyframe* keyframe = CSSParser::parseKeyframeRule(context, ruleText); 104 StyleRuleKeyframe* keyframe = CSSParser::parseKeyframeRule(context, ruleText);
105 if (!keyframe) 105 if (!keyframe)
106 return; 106 return;
107 107
108 CSSStyleSheet::RuleMutationScope mutationScope(this); 108 CSSStyleSheet::RuleMutationScope mutationScope(this);
109 109
110 m_keyframesRule->wrapperAppendKeyframe(keyframe); 110 m_keyframesRule->wrapperAppendKeyframe(keyframe);
111 111
112 m_childRuleCSSOMWrappers.grow(length()); 112 m_childRuleCSSOMWrappers.grow(length());
113 } 113 }
114 114
115 void CSSKeyframesRule::deleteRule(const String& s) { 115 void CSSKeyframesRule::deleteRule(const String& s) {
116 ASSERT(m_childRuleCSSOMWrappers.size() == 116 DCHECK_EQ(m_childRuleCSSOMWrappers.size(),
117 m_keyframesRule->keyframes().size()); 117 m_keyframesRule->keyframes().size());
118 118
119 int i = m_keyframesRule->findKeyframeIndex(s); 119 int i = m_keyframesRule->findKeyframeIndex(s);
120 if (i < 0) 120 if (i < 0)
121 return; 121 return;
122 122
123 CSSStyleSheet::RuleMutationScope mutationScope(this); 123 CSSStyleSheet::RuleMutationScope mutationScope(this);
124 124
125 m_keyframesRule->wrapperRemoveKeyframe(i); 125 m_keyframesRule->wrapperRemoveKeyframe(i);
126 126
127 if (m_childRuleCSSOMWrappers[i]) 127 if (m_childRuleCSSOMWrappers[i])
(...skipping 26 matching lines...) Expand all
154 } 154 }
155 155
156 unsigned CSSKeyframesRule::length() const { 156 unsigned CSSKeyframesRule::length() const {
157 return m_keyframesRule->keyframes().size(); 157 return m_keyframesRule->keyframes().size();
158 } 158 }
159 159
160 CSSKeyframeRule* CSSKeyframesRule::item(unsigned index) const { 160 CSSKeyframeRule* CSSKeyframesRule::item(unsigned index) const {
161 if (index >= length()) 161 if (index >= length())
162 return nullptr; 162 return nullptr;
163 163
164 ASSERT(m_childRuleCSSOMWrappers.size() == 164 DCHECK_EQ(m_childRuleCSSOMWrappers.size(),
165 m_keyframesRule->keyframes().size()); 165 m_keyframesRule->keyframes().size());
166 Member<CSSKeyframeRule>& rule = m_childRuleCSSOMWrappers[index]; 166 Member<CSSKeyframeRule>& rule = m_childRuleCSSOMWrappers[index];
167 if (!rule) 167 if (!rule)
168 rule = new CSSKeyframeRule(m_keyframesRule->keyframes()[index].get(), 168 rule = new CSSKeyframeRule(m_keyframesRule->keyframes()[index].get(),
169 const_cast<CSSKeyframesRule*>(this)); 169 const_cast<CSSKeyframesRule*>(this));
170 170
171 return rule.get(); 171 return rule.get();
172 } 172 }
173 173
174 CSSKeyframeRule* CSSKeyframesRule::anonymousIndexedGetter( 174 CSSKeyframeRule* CSSKeyframesRule::anonymousIndexedGetter(
175 unsigned index) const { 175 unsigned index) const {
176 const Document* parentDocument = 176 const Document* parentDocument =
177 CSSStyleSheet::singleOwnerDocument(parentStyleSheet()); 177 CSSStyleSheet::singleOwnerDocument(parentStyleSheet());
178 if (parentDocument) { 178 if (parentDocument) {
179 UseCounter::count(*parentDocument, 179 UseCounter::count(*parentDocument,
180 UseCounter::CSSKeyframesRuleAnonymousIndexedGetter); 180 UseCounter::CSSKeyframesRuleAnonymousIndexedGetter);
181 } 181 }
182 return item(index); 182 return item(index);
183 } 183 }
184 184
185 CSSRuleList* CSSKeyframesRule::cssRules() const { 185 CSSRuleList* CSSKeyframesRule::cssRules() const {
186 if (!m_ruleListCSSOMWrapper) 186 if (!m_ruleListCSSOMWrapper)
187 m_ruleListCSSOMWrapper = LiveCSSRuleList<CSSKeyframesRule>::create( 187 m_ruleListCSSOMWrapper = LiveCSSRuleList<CSSKeyframesRule>::create(
188 const_cast<CSSKeyframesRule*>(this)); 188 const_cast<CSSKeyframesRule*>(this));
189 return m_ruleListCSSOMWrapper.get(); 189 return m_ruleListCSSOMWrapper.get();
190 } 190 }
191 191
192 void CSSKeyframesRule::reattach(StyleRuleBase* rule) { 192 void CSSKeyframesRule::reattach(StyleRuleBase* rule) {
193 ASSERT(rule); 193 DCHECK(rule);
194 m_keyframesRule = toStyleRuleKeyframes(rule); 194 m_keyframesRule = toStyleRuleKeyframes(rule);
195 } 195 }
196 196
197 DEFINE_TRACE(CSSKeyframesRule) { 197 DEFINE_TRACE(CSSKeyframesRule) {
198 CSSRule::trace(visitor); 198 CSSRule::trace(visitor);
199 visitor->trace(m_childRuleCSSOMWrappers); 199 visitor->trace(m_childRuleCSSOMWrappers);
200 visitor->trace(m_keyframesRule); 200 visitor->trace(m_keyframesRule);
201 visitor->trace(m_ruleListCSSOMWrapper); 201 visitor->trace(m_ruleListCSSOMWrapper);
202 } 202 }
203 203
204 } // namespace blink 204 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698