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

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

Issue 2315923002: Lazy Parse CSS (Closed)
Patch Set: esprehn review Created 4 years, 1 month 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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) 3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 rule->setParentRule(parentRule); 201 rule->setParentRule(parentRule);
202 return rule; 202 return rule;
203 } 203 }
204 204
205 unsigned StyleRule::averageSizeInBytes() { 205 unsigned StyleRule::averageSizeInBytes() {
206 return sizeof(StyleRule) + sizeof(CSSSelector) + 206 return sizeof(StyleRule) + sizeof(CSSSelector) +
207 StylePropertySet::averageSizeInBytes(); 207 StylePropertySet::averageSizeInBytes();
208 } 208 }
209 209
210 StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties) 210 StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties)
211 : StyleRuleBase(Style), m_properties(properties) { 211 : StyleRuleBase(Style),
212 m_selectorList = std::move(selectorList); 212 m_selectorList(std::move(selectorList)),
213 m_properties(properties) {}
214
215 StyleRule::StyleRule(CSSSelectorList selectorList,
216 CSSLazyPropertyParser* lazyPropertyParser)
217 : StyleRuleBase(Style),
218 m_selectorList(std::move(selectorList)),
219 m_lazyPropertyParser(lazyPropertyParser) {}
220
221 const StylePropertySet& StyleRule::properties() const {
222 if (!m_properties) {
223 m_properties = m_lazyPropertyParser->parseProperties();
224 m_lazyPropertyParser.clear();
225 }
226 return *m_properties;
213 } 227 }
214 228
215 StyleRule::StyleRule(const StyleRule& rule) 229 StyleRule::StyleRule(const StyleRule& o)
216 : StyleRuleBase(rule), 230 : StyleRuleBase(o),
217 m_properties(rule.m_properties->mutableCopy()), 231 m_selectorList(o.m_selectorList.copy()),
218 m_selectorList(rule.m_selectorList.copy()) {} 232 m_properties(o.properties().mutableCopy()) {}
219 233
220 StyleRule::~StyleRule() {} 234 StyleRule::~StyleRule() {}
221 235
222 MutableStylePropertySet& StyleRule::mutableProperties() { 236 MutableStylePropertySet& StyleRule::mutableProperties() {
223 if (!m_properties->isMutable()) 237 // Ensure m_properties is initialized.
238 if (!properties().isMutable())
224 m_properties = m_properties->mutableCopy(); 239 m_properties = m_properties->mutableCopy();
225 return *toMutableStylePropertySet(m_properties.get()); 240 return *toMutableStylePropertySet(m_properties.get());
226 } 241 }
227 242
243 bool StyleRule::propertiesHaveFailedOrCanceledSubresources() const {
244 return m_properties && m_properties->hasFailedOrCanceledSubresources();
245 }
246
247 bool StyleRule::shouldConsiderForMatchingRules(bool includeEmptyRules) const {
248 // Consider all non-empty property sets if parsing has not been deferred.
249 // Otherwise, consider all StyleRules with non-null deferred closures.
250 return includeEmptyRules || !m_properties || !m_properties->isEmpty();
251 }
252
228 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) { 253 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) {
229 visitor->trace(m_properties); 254 visitor->trace(m_properties);
255 visitor->trace(m_lazyPropertyParser);
230 StyleRuleBase::traceAfterDispatch(visitor); 256 StyleRuleBase::traceAfterDispatch(visitor);
231 } 257 }
232 258
233 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, 259 StyleRulePage::StyleRulePage(CSSSelectorList selectorList,
234 StylePropertySet* properties) 260 StylePropertySet* properties)
235 : StyleRuleBase(Page), 261 : StyleRuleBase(Page),
236 m_properties(properties), 262 m_properties(properties),
237 m_selectorList(std::move(selectorList)) {} 263 m_selectorList(std::move(selectorList)) {}
238 264
239 StyleRulePage::StyleRulePage(const StyleRulePage& pageRule) 265 StyleRulePage::StyleRulePage(const StyleRulePage& pageRule)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 m_properties = m_properties->mutableCopy(); 380 m_properties = m_properties->mutableCopy();
355 return *toMutableStylePropertySet(m_properties); 381 return *toMutableStylePropertySet(m_properties);
356 } 382 }
357 383
358 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) { 384 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) {
359 visitor->trace(m_properties); 385 visitor->trace(m_properties);
360 StyleRuleBase::traceAfterDispatch(visitor); 386 StyleRuleBase::traceAfterDispatch(visitor);
361 } 387 }
362 388
363 } // namespace blink 389 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/StyleRule.h ('k') | third_party/WebKit/Source/core/css/StyleSheetContents.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698