2 * Copyright (c) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
31 #ifndef CSSPropertySourceData_h
32 #define CSSPropertySourceData_h
34 #include "platform/heap/Handle.h"
35 #include "wtf/Forward.h"
36 #include "wtf/RefCounted.h"
37 #include "wtf/Vector.h"
38 #include "wtf/text/WTFString.h"
43 ALLOW_ONLY_INLINE_ALLOCATION();
46 SourceRange(unsigned start, unsigned end);
47 unsigned length() const;
49 void trace(Visitor*) { }
55 struct CSSPropertySourceData {
56 ALLOW_ONLY_INLINE_ALLOCATION();
58 CSSPropertySourceData(const String& name, const String& value, bool important, bool disabled, bool parsedOk, const SourceRange& range);
59 CSSPropertySourceData(const CSSPropertySourceData& other);
60 CSSPropertySourceData();
62 String toString() const;
63 unsigned hash() const;
65 void trace(Visitor* visitor) { visitor->trace(range); }
75 struct CSSStyleSourceData : public RefCountedWillBeGarbageCollected<CSSStyleSourceData> {
76 static PassRefPtrWillBeRawPtr<CSSStyleSourceData> create()
78 return adoptRefWillBeNoop(new CSSStyleSourceData());
81 void trace(Visitor* visitor) { visitor->trace(propertyData); }
83 WillBeHeapVector<CSSPropertySourceData> propertyData;
86 struct CSSRuleSourceData;
87 typedef WillBeHeapVector<RefPtrWillBeMember<CSSRuleSourceData> > RuleSourceDataList;
88 typedef WillBeHeapVector<SourceRange> SelectorRangeList;
90 struct CSSRuleSourceData : public RefCountedWillBeGarbageCollected<CSSRuleSourceData> {
105 static PassRefPtrWillBeRawPtr<CSSRuleSourceData> create(Type type)
107 return adoptRefWillBeNoop(new CSSRuleSourceData(type));
110 static PassRefPtrWillBeRawPtr<CSSRuleSourceData> createUnknown()
112 return adoptRefWillBeNoop(new CSSRuleSourceData(UNKNOWN_RULE));
115 CSSRuleSourceData(Type type)
118 if (type == STYLE_RULE || type == FONT_FACE_RULE || type == PAGE_RULE)
119 styleSourceData = CSSStyleSourceData::create();
122 void trace(Visitor*);
126 // Range of the selector list in the enclosing source.
127 SourceRange ruleHeaderRange;
129 // Range of the rule body (e.g. style text for style rules) in the enclosing source.
130 SourceRange ruleBodyRange;
132 // Only for CSSStyleRules.
133 SelectorRangeList selectorRanges;
135 // Only for CSSStyleRules, CSSFontFaceRules, and CSSPageRules.
136 RefPtrWillBeMember<CSSStyleSourceData> styleSourceData;
138 // Only for CSSMediaRules.
139 RuleSourceDataList childRules;
144 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::SourceRange);
145 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::CSSPropertySourceData);
147 #endif // CSSPropertySourceData_h