Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #ifndef StyleRule_h | 22 #ifndef StyleRule_h |
| 23 #define StyleRule_h | 23 #define StyleRule_h |
| 24 | 24 |
| 25 #include "core/CoreExport.h" | 25 #include "core/CoreExport.h" |
| 26 #include "core/css/CSSSelectorList.h" | 26 #include "core/css/CSSSelectorList.h" |
| 27 #include "core/css/MediaList.h" | 27 #include "core/css/MediaList.h" |
| 28 #include "core/css/StylePropertySet.h" | 28 #include "core/css/StylePropertySet.h" |
| 29 #include "core/css/parser/CSSParser.h" | |
|
Timothy Loh
2016/09/27 05:15:45
This include isn't needed now :)
Charlie Harrison
2016/09/27 13:22:00
Done.
| |
| 29 #include "platform/heap/Handle.h" | 30 #include "platform/heap/Handle.h" |
| 30 #include "wtf/RefPtr.h" | 31 #include "wtf/RefPtr.h" |
| 31 | 32 |
| 32 namespace blink { | 33 namespace blink { |
| 33 | 34 |
| 34 class CSSRule; | 35 class CSSRule; |
| 35 class CSSStyleSheet; | 36 class CSSStyleSheet; |
| 36 | 37 |
| 37 class CORE_EXPORT StyleRuleBase : public GarbageCollectedFinalized<StyleRuleBase > { | 38 class CORE_EXPORT StyleRuleBase : public GarbageCollectedFinalized<StyleRuleBase > { |
| 38 public: | 39 public: |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 unsigned m_type : 5; | 91 unsigned m_type : 5; |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 class CORE_EXPORT StyleRule : public StyleRuleBase { | 94 class CORE_EXPORT StyleRule : public StyleRuleBase { |
| 94 public: | 95 public: |
| 95 // Adopts the selector list | 96 // Adopts the selector list |
| 96 static StyleRule* create(CSSSelectorList selectorList, StylePropertySet* pro perties) | 97 static StyleRule* create(CSSSelectorList selectorList, StylePropertySet* pro perties) |
| 97 { | 98 { |
| 98 return new StyleRule(std::move(selectorList), properties); | 99 return new StyleRule(std::move(selectorList), properties); |
| 99 } | 100 } |
| 101 static StyleRule* createLazy(CSSSelectorList selectorList, std::unique_ptr<D eferredPropertiesClosure> deferredProperties) | |
| 102 { | |
| 103 return new StyleRule(std::move(selectorList), std::move(deferredProperti es)); | |
| 104 } | |
| 100 | 105 |
| 101 ~StyleRule(); | 106 ~StyleRule(); |
| 102 | 107 |
| 103 const CSSSelectorList& selectorList() const { return m_selectorList; } | 108 const CSSSelectorList& selectorList() const { return m_selectorList; } |
| 104 const StylePropertySet& properties() const { return *m_properties; } | 109 const StylePropertySet& properties() const; |
| 105 MutableStylePropertySet& mutableProperties(); | 110 MutableStylePropertySet& mutableProperties(); |
| 106 | 111 |
| 107 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList = std::move(selectors); } | 112 void wrapperAdoptSelectorList(CSSSelectorList selectors) { m_selectorList = std::move(selectors); } |
| 108 | 113 |
| 109 StyleRule* copy() const { return new StyleRule(*this); } | 114 StyleRule* copy() const { return new StyleRule(*this); } |
| 110 | 115 |
| 111 static unsigned averageSizeInBytes(); | 116 static unsigned averageSizeInBytes(); |
| 112 | 117 |
| 118 // Helper methods to avoid parsing lazy properties when not needed. | |
| 119 bool propertiesHaveFailedOrCanceledSubresources() const; | |
| 120 bool hasEmptyProperties() const; | |
| 121 | |
| 113 DECLARE_TRACE_AFTER_DISPATCH(); | 122 DECLARE_TRACE_AFTER_DISPATCH(); |
| 114 | 123 |
| 115 private: | 124 private: |
| 116 StyleRule(CSSSelectorList, StylePropertySet*); | 125 StyleRule(CSSSelectorList, StylePropertySet*); |
| 126 StyleRule(CSSSelectorList, std::unique_ptr<DeferredPropertiesClosure>); | |
| 117 StyleRule(const StyleRule&); | 127 StyleRule(const StyleRule&); |
| 118 | 128 |
| 119 Member<StylePropertySet> m_properties; // Cannot be null. | |
| 120 CSSSelectorList m_selectorList; | 129 CSSSelectorList m_selectorList; |
| 130 mutable Member<StylePropertySet> m_properties; | |
| 131 mutable std::unique_ptr<DeferredPropertiesClosure> m_deferred; | |
| 121 }; | 132 }; |
| 122 | 133 |
| 123 class StyleRuleFontFace : public StyleRuleBase { | 134 class StyleRuleFontFace : public StyleRuleBase { |
| 124 public: | 135 public: |
| 125 static StyleRuleFontFace* create(StylePropertySet* properties) | 136 static StyleRuleFontFace* create(StylePropertySet* properties) |
| 126 { | 137 { |
| 127 return new StyleRuleFontFace(properties); | 138 return new StyleRuleFontFace(properties); |
| 128 } | 139 } |
| 129 | 140 |
| 130 ~StyleRuleFontFace(); | 141 ~StyleRuleFontFace(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 DEFINE_STYLE_RULE_TYPE_CASTS(FontFace); | 281 DEFINE_STYLE_RULE_TYPE_CASTS(FontFace); |
| 271 DEFINE_STYLE_RULE_TYPE_CASTS(Page); | 282 DEFINE_STYLE_RULE_TYPE_CASTS(Page); |
| 272 DEFINE_STYLE_RULE_TYPE_CASTS(Media); | 283 DEFINE_STYLE_RULE_TYPE_CASTS(Media); |
| 273 DEFINE_STYLE_RULE_TYPE_CASTS(Supports); | 284 DEFINE_STYLE_RULE_TYPE_CASTS(Supports); |
| 274 DEFINE_STYLE_RULE_TYPE_CASTS(Viewport); | 285 DEFINE_STYLE_RULE_TYPE_CASTS(Viewport); |
| 275 DEFINE_STYLE_RULE_TYPE_CASTS(Charset); | 286 DEFINE_STYLE_RULE_TYPE_CASTS(Charset); |
| 276 | 287 |
| 277 } // namespace blink | 288 } // namespace blink |
| 278 | 289 |
| 279 #endif // StyleRule_h | 290 #endif // StyleRule_h |
| OLD | NEW |