| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 Google Inc. All rights reserved. | 2 * Copyright (c) 2010 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef CSSPropertySourceData_h | 31 #ifndef CSSPropertySourceData_h |
| 32 #define CSSPropertySourceData_h | 32 #define CSSPropertySourceData_h |
| 33 | 33 |
| 34 #include "core/css/StyleRule.h" | 34 #include "core/css/StyleRule.h" |
| 35 #include "platform/heap/Handle.h" | 35 #include "platform/heap/Handle.h" |
| 36 #include "wtf/Forward.h" | 36 #include "wtf/Forward.h" |
| 37 #include "wtf/RefCounted.h" |
| 37 #include "wtf/Vector.h" | 38 #include "wtf/Vector.h" |
| 38 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 struct SourceRange { | 43 class SourceRange { |
| 43 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 44 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 44 public: | 45 public: |
| 45 SourceRange(); | 46 SourceRange(); |
| 46 SourceRange(unsigned start, unsigned end); | 47 SourceRange(unsigned start, unsigned end); |
| 47 unsigned length() const; | 48 unsigned length() const; |
| 48 | 49 |
| 49 DEFINE_INLINE_TRACE() { } | |
| 50 | |
| 51 unsigned start; | 50 unsigned start; |
| 52 unsigned end; | 51 unsigned end; |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 } // namespace blink | 54 } // namespace blink |
| 56 | 55 |
| 57 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::SourceRange); | 56 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::SourceRange); |
| 58 | 57 |
| 59 namespace blink { | 58 namespace blink { |
| 60 | 59 |
| 61 struct CSSPropertySourceData { | 60 class CSSPropertySourceData { |
| 62 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 61 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 63 public: | 62 public: |
| 64 CSSPropertySourceData(const String& name, const String& value, bool importan
t, bool disabled, bool parsedOk, const SourceRange& range); | 63 CSSPropertySourceData(const String& name, const String& value, bool importan
t, bool disabled, bool parsedOk, const SourceRange& range); |
| 65 CSSPropertySourceData(const CSSPropertySourceData& other); | 64 CSSPropertySourceData(const CSSPropertySourceData& other); |
| 66 | 65 |
| 67 DEFINE_INLINE_TRACE() { visitor->trace(range); } | |
| 68 | |
| 69 String name; | 66 String name; |
| 70 String value; | 67 String value; |
| 71 bool important; | 68 bool important; |
| 72 bool disabled; | 69 bool disabled; |
| 73 bool parsedOk; | 70 bool parsedOk; |
| 74 SourceRange range; | 71 SourceRange range; |
| 75 }; | 72 }; |
| 76 | 73 |
| 77 } // namespace blink | 74 } // namespace blink |
| 78 | 75 |
| 79 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSPropertySourceData); | 76 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSPropertySourceData); |
| 80 | 77 |
| 81 namespace blink { | 78 namespace blink { |
| 82 | 79 |
| 83 struct CSSStyleSourceData : public GarbageCollected<CSSStyleSourceData> { | 80 class CSSStyleSourceData { |
| 84 static CSSStyleSourceData* create() | 81 USING_FAST_MALLOC(CSSStyleSourceData); |
| 82 public: |
| 83 static std::unique_ptr<CSSStyleSourceData> create() |
| 85 { | 84 { |
| 86 return new CSSStyleSourceData(); | 85 return wrapUnique(new CSSStyleSourceData); |
| 87 } | 86 } |
| 88 | 87 |
| 89 DEFINE_INLINE_TRACE() | 88 Vector<CSSPropertySourceData> propertyData; |
| 90 { | |
| 91 visitor->trace(propertyData); | |
| 92 } | |
| 93 | |
| 94 HeapVector<CSSPropertySourceData> propertyData; | |
| 95 }; | 89 }; |
| 96 | 90 |
| 97 struct CSSMediaQueryExpSourceData { | 91 class CSSMediaQueryExpSourceData { |
| 98 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 92 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 99 public: | 93 public: |
| 100 CSSMediaQueryExpSourceData(const SourceRange& valueRange) | 94 CSSMediaQueryExpSourceData(const SourceRange& valueRange) |
| 101 : valueRange(valueRange) { } | 95 : valueRange(valueRange) { } |
| 102 | 96 |
| 103 DEFINE_INLINE_TRACE() { visitor->trace(valueRange); } | |
| 104 | |
| 105 SourceRange valueRange; | 97 SourceRange valueRange; |
| 106 }; | 98 }; |
| 107 | 99 |
| 108 } // namespace blink | 100 } // namespace blink |
| 109 | 101 |
| 110 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSMediaQueryExpSourceData); | 102 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSMediaQueryExpSourceData); |
| 111 | 103 |
| 112 namespace blink { | 104 namespace blink { |
| 113 | 105 |
| 114 struct CSSMediaQuerySourceData : public GarbageCollected<CSSMediaQuerySourceData
> { | 106 class CSSMediaQuerySourceData { |
| 115 static CSSMediaQuerySourceData* create() | 107 public: |
| 108 static std::unique_ptr<CSSMediaQuerySourceData> create() |
| 116 { | 109 { |
| 117 return new CSSMediaQuerySourceData(); | 110 return wrapUnique(new CSSMediaQuerySourceData); |
| 118 } | 111 } |
| 119 | 112 |
| 120 DEFINE_INLINE_TRACE() | 113 Vector<CSSMediaQueryExpSourceData> expData; |
| 114 }; |
| 115 |
| 116 class CSSMediaSourceData { |
| 117 USING_FAST_MALLOC(CSSMediaSourceData); |
| 118 public: |
| 119 static std::unique_ptr<CSSMediaSourceData> create() |
| 121 { | 120 { |
| 122 visitor->trace(expData); | 121 return wrapUnique(new CSSMediaSourceData); |
| 123 } | 122 } |
| 124 | 123 |
| 125 HeapVector<CSSMediaQueryExpSourceData> expData; | 124 Vector<std::unique_ptr<CSSMediaQuerySourceData>> queryData; |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 struct CSSMediaSourceData : public GarbageCollected<CSSMediaSourceData> { | 127 class CSSRuleSourceData; |
| 129 static CSSMediaSourceData* create() | 128 using RuleSourceDataList = Vector<RefPtr<CSSRuleSourceData>>; |
| 129 using SelectorRangeList = Vector<SourceRange>; |
| 130 |
| 131 class CSSRuleSourceData : public RefCounted<CSSRuleSourceData> { |
| 132 public: |
| 133 static PassRefPtr<CSSRuleSourceData> create(StyleRule::RuleType type) |
| 130 { | 134 { |
| 131 return new CSSMediaSourceData(); | 135 return adoptRef(new CSSRuleSourceData(type)); |
| 132 } | 136 } |
| 133 | 137 |
| 134 DEFINE_INLINE_TRACE() | |
| 135 { | |
| 136 visitor->trace(queryData); | |
| 137 } | |
| 138 | |
| 139 HeapVector<Member<CSSMediaQuerySourceData>> queryData; | |
| 140 }; | |
| 141 | |
| 142 struct CSSRuleSourceData; | |
| 143 using RuleSourceDataList = HeapVector<Member<CSSRuleSourceData>>; | |
| 144 using SelectorRangeList = HeapVector<SourceRange>; | |
| 145 | |
| 146 struct CSSRuleSourceData : public GarbageCollected<CSSRuleSourceData> { | |
| 147 static CSSRuleSourceData* create(StyleRule::RuleType type) | |
| 148 { | |
| 149 return new CSSRuleSourceData(type); | |
| 150 } | |
| 151 | |
| 152 CSSRuleSourceData(StyleRule::RuleType type) | |
| 153 : type(type) | |
| 154 { | |
| 155 if (type == StyleRule::Style || type == StyleRule::FontFace || type == S
tyleRule::Page || type == StyleRule::Keyframe) | |
| 156 styleSourceData = CSSStyleSourceData::create(); | |
| 157 if (type == StyleRule::Media || type == StyleRule::Import) | |
| 158 mediaSourceData = CSSMediaSourceData::create(); | |
| 159 } | |
| 160 | |
| 161 DECLARE_TRACE(); | |
| 162 | |
| 163 StyleRule::RuleType type; | 138 StyleRule::RuleType type; |
| 164 | 139 |
| 165 // Range of the selector list in the enclosing source. | 140 // Range of the selector list in the enclosing source. |
| 166 SourceRange ruleHeaderRange; | 141 SourceRange ruleHeaderRange; |
| 167 | 142 |
| 168 // Range of the rule body (e.g. style text for style rules) in the enclosing
source. | 143 // Range of the rule body (e.g. style text for style rules) in the enclosing
source. |
| 169 SourceRange ruleBodyRange; | 144 SourceRange ruleBodyRange; |
| 170 | 145 |
| 171 // Only for CSSStyleRules. | 146 // Only for CSSStyleRules. |
| 172 SelectorRangeList selectorRanges; | 147 SelectorRangeList selectorRanges; |
| 173 | 148 |
| 174 // Only for CSSStyleRules, CSSFontFaceRules, and CSSPageRules. | 149 // Only for CSSStyleRules, CSSFontFaceRules, and CSSPageRules. |
| 175 Member<CSSStyleSourceData> styleSourceData; | 150 std::unique_ptr<CSSStyleSourceData> styleSourceData; |
| 176 | 151 |
| 177 // Only for CSSMediaRules. | 152 // Only for CSSMediaRules. |
| 178 RuleSourceDataList childRules; | 153 RuleSourceDataList childRules; |
| 179 | 154 |
| 180 // Only for CSSMediaRules and CSSImportRules. | 155 // Only for CSSMediaRules and CSSImportRules. |
| 181 Member<CSSMediaSourceData> mediaSourceData; | 156 std::unique_ptr<CSSMediaSourceData> mediaSourceData; |
| 157 |
| 158 private: |
| 159 CSSRuleSourceData(StyleRule::RuleType type) |
| 160 : type(type) |
| 161 { |
| 162 if (type == StyleRule::Style || type == StyleRule::FontFace || type == S
tyleRule::Page || type == StyleRule::Keyframe) |
| 163 styleSourceData = CSSStyleSourceData::create(); |
| 164 if (type == StyleRule::Media || type == StyleRule::Import) |
| 165 mediaSourceData = CSSMediaSourceData::create(); |
| 166 } |
| 167 |
| 182 }; | 168 }; |
| 183 | 169 |
| 184 } // namespace blink | 170 } // namespace blink |
| 185 | 171 |
| 186 #endif // CSSPropertySourceData_h | 172 #endif // CSSPropertySourceData_h |
| OLD | NEW |