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

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

Issue 2315923002: Lazy Parse CSS (Closed)
Patch Set: s/->/. Created 4 years, 2 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 * (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, 2006, 2008, 2012, 2013 Apple Inc. All rights reserved. 4 * Copyright (C) 2002, 2006, 2008, 2012, 2013 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 unsigned m_type : 5; 90 unsigned m_type : 5;
91 }; 91 };
92 92
93 class CORE_EXPORT StyleRule : public StyleRuleBase { 93 class CORE_EXPORT StyleRule : public StyleRuleBase {
94 public: 94 public:
95 // Adopts the selector list 95 // Adopts the selector list
96 static StyleRule* create(CSSSelectorList selectorList, StylePropertySet* pro perties) 96 static StyleRule* create(CSSSelectorList selectorList, StylePropertySet* pro perties)
97 { 97 {
98 return new StyleRule(std::move(selectorList), properties); 98 return new StyleRule(std::move(selectorList), properties);
99 } 99 }
100 static StyleRule* createLazy(CSSSelectorList selectorList, std::unique_ptr<D eferredPropertiesClosure> deferredProperties)
101 {
102 return new StyleRule(std::move(selectorList), std::move(deferredProperti es));
103 }
100 104
101 ~StyleRule(); 105 ~StyleRule();
102 106
103 const CSSSelectorList& selectorList() const { return m_selectorList; } 107 const CSSSelectorList& selectorList() const { return m_selectorList; }
104 const StylePropertySet& properties() const { return *m_properties; } 108 const StylePropertySet& properties() const;
105 MutableStylePropertySet& mutableProperties(); 109 MutableStylePropertySet& mutableProperties();
106 110
107 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList = std::move(selectors); } 111 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList = std::move(selectors); }
108 112
109 StyleRule* copy() const { return new StyleRule(*this); } 113 StyleRule* copy() const { return new StyleRule(*this); }
110 114
111 static unsigned averageSizeInBytes(); 115 static unsigned averageSizeInBytes();
112 116
117 // Helper methods to avoid parsing lazy properties when not needed.
118 bool propertiesHaveFailedOrCanceledSubresources() const;
119 bool shouldConsiderForMatchingRules(bool includeEmptyRules) const;
120
113 DECLARE_TRACE_AFTER_DISPATCH(); 121 DECLARE_TRACE_AFTER_DISPATCH();
114 122
115 private: 123 private:
116 StyleRule(CSSSelectorList, StylePropertySet*); 124 StyleRule(CSSSelectorList, StylePropertySet*);
125 StyleRule(CSSSelectorList, std::unique_ptr<DeferredPropertiesClosure>);
117 StyleRule(const StyleRule&); 126 StyleRule(const StyleRule&);
118 127
119 Member<StylePropertySet> m_properties; // Cannot be null.
120 CSSSelectorList m_selectorList; 128 CSSSelectorList m_selectorList;
129 mutable Member<StylePropertySet> m_properties;
130 mutable std::unique_ptr<DeferredPropertiesClosure> m_deferred;
121 }; 131 };
122 132
123 class StyleRuleFontFace : public StyleRuleBase { 133 class StyleRuleFontFace : public StyleRuleBase {
124 public: 134 public:
125 static StyleRuleFontFace* create(StylePropertySet* properties) 135 static StyleRuleFontFace* create(StylePropertySet* properties)
126 { 136 {
127 return new StyleRuleFontFace(properties); 137 return new StyleRuleFontFace(properties);
128 } 138 }
129 139
130 ~StyleRuleFontFace(); 140 ~StyleRuleFontFace();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 DEFINE_STYLE_RULE_TYPE_CASTS(FontFace); 280 DEFINE_STYLE_RULE_TYPE_CASTS(FontFace);
271 DEFINE_STYLE_RULE_TYPE_CASTS(Page); 281 DEFINE_STYLE_RULE_TYPE_CASTS(Page);
272 DEFINE_STYLE_RULE_TYPE_CASTS(Media); 282 DEFINE_STYLE_RULE_TYPE_CASTS(Media);
273 DEFINE_STYLE_RULE_TYPE_CASTS(Supports); 283 DEFINE_STYLE_RULE_TYPE_CASTS(Supports);
274 DEFINE_STYLE_RULE_TYPE_CASTS(Viewport); 284 DEFINE_STYLE_RULE_TYPE_CASTS(Viewport);
275 DEFINE_STYLE_RULE_TYPE_CASTS(Charset); 285 DEFINE_STYLE_RULE_TYPE_CASTS(Charset);
276 286
277 } // namespace blink 287 } // namespace blink
278 288
279 #endif // StyleRule_h 289 #endif // StyleRule_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698