OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google 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 15 matching lines...) Expand all Loading... | |
26 #include "core/css/RuleSet.h" | 26 #include "core/css/RuleSet.h" |
27 #include "core/css/SelectorChecker.h" | 27 #include "core/css/SelectorChecker.h" |
28 #include "wtf/RefPtr.h" | 28 #include "wtf/RefPtr.h" |
29 #include "wtf/Vector.h" | 29 #include "wtf/Vector.h" |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 class StylePropertySet; | 33 class StylePropertySet; |
34 class StyleRule; | 34 class StyleRule; |
35 | 35 |
36 struct RuleRange { | 36 class RuleRange { |
37 RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(firstRule Index), lastRuleIndex(lastRuleIndex) { } | 37 public: |
38 int& firstRuleIndex; | 38 RuleRange() : m_firstRuleIndex(-1), m_lastRuleIndex(-1) { } |
39 int& lastRuleIndex; | 39 RuleRange(int firstRuleIndex, int lastRuleIndex) : m_firstRuleIndex(firstRul eIndex), m_lastRuleIndex(lastRuleIndex) { } |
esprehn
2014/03/27 08:41:59
The initializer should be on a different line.
Ru
| |
40 | |
41 int first() const { return m_firstRuleIndex; } | |
42 int last() const { return m_lastRuleIndex; } | |
43 | |
44 bool collapsed() const { return m_firstRuleIndex == -1; } | |
45 | |
46 void setLast(int position) { m_lastRuleIndex = position; } | |
47 | |
48 void shiftLast(int position) | |
49 { | |
50 m_lastRuleIndex = position; | |
esprehn
2014/03/27 08:41:59
This doesn't seem to shift the last, it seems to a
| |
51 if (m_firstRuleIndex == -1) | |
52 m_firstRuleIndex = position; | |
53 } | |
54 | |
55 void shiftLastByOne() | |
56 { | |
57 ++m_lastRuleIndex; | |
58 if (m_firstRuleIndex == -1) | |
59 m_firstRuleIndex = m_lastRuleIndex; | |
60 } | |
61 | |
62 private: | |
63 int m_firstRuleIndex; | |
64 int m_lastRuleIndex; | |
40 }; | 65 }; |
41 | 66 |
42 struct MatchRanges { | 67 inline bool operator==(const RuleRange& a, const RuleRange& b) |
43 MatchRanges() : firstUARule(-1), lastUARule(-1), firstAuthorRule(-1), lastAu thorRule(-1), firstUserRule(-1), lastUserRule(-1) { } | 68 { |
44 int firstUARule; | 69 return a.first() == b.first() && a.last() == b.last(); |
45 int lastUARule; | 70 } |
46 int firstAuthorRule; | 71 |
47 int lastAuthorRule; | 72 class MatchRanges { |
48 int firstUserRule; | 73 public: |
49 int lastUserRule; | 74 MatchRanges() { } |
esprehn
2014/03/27 08:41:59
Leave off the default constructor, the compiler wi
| |
50 RuleRange UARuleRange() { return RuleRange(firstUARule, lastUARule); } | 75 |
51 RuleRange authorRuleRange() { return RuleRange(firstAuthorRule, lastAuthorRu le); } | 76 RuleRange& UARuleRange() { return m_uaRuleRange; } |
esprehn
2014/03/27 08:41:59
ua should be lower case.
| |
52 RuleRange userRuleRange() { return RuleRange(firstUserRule, lastUserRule); } | 77 RuleRange& authorRuleRange() { return m_authorRuleRange; } |
78 RuleRange& userRuleRange() { return m_userRuleRange; } | |
79 | |
80 const RuleRange& UARuleRange() const { return m_uaRuleRange; } | |
esprehn
2014/03/27 08:41:59
ditto
| |
81 const RuleRange& authorRuleRange() const { return m_authorRuleRange; } | |
82 const RuleRange& userRuleRange() const { return m_userRuleRange; } | |
83 | |
84 private: | |
85 RuleRange m_uaRuleRange; | |
86 RuleRange m_authorRuleRange; | |
87 RuleRange m_userRuleRange; | |
53 }; | 88 }; |
54 | 89 |
55 struct MatchedProperties { | 90 struct MatchedProperties { |
56 MatchedProperties(); | 91 MatchedProperties(); |
57 ~MatchedProperties(); | 92 ~MatchedProperties(); |
58 | 93 |
59 RefPtr<StylePropertySet> properties; | 94 RefPtr<StylePropertySet> properties; |
60 union { | 95 union { |
61 struct { | 96 struct { |
62 unsigned linkMatchType : 2; | 97 unsigned linkMatchType : 2; |
(...skipping 11 matching lines...) Expand all Loading... | |
74 Vector<MatchedProperties, 64> matchedProperties; | 109 Vector<MatchedProperties, 64> matchedProperties; |
75 WillBeHeapVector<RawPtrWillBeMember<StyleRule>, 64> matchedRules; | 110 WillBeHeapVector<RawPtrWillBeMember<StyleRule>, 64> matchedRules; |
76 MatchRanges ranges; | 111 MatchRanges ranges; |
77 bool isCacheable; | 112 bool isCacheable; |
78 | 113 |
79 void addMatchedProperties(const StylePropertySet* properties, StyleRule* = 0 , unsigned linkMatchType = SelectorChecker::MatchAll, PropertyWhitelistType = Pr opertyWhitelistNone); | 114 void addMatchedProperties(const StylePropertySet* properties, StyleRule* = 0 , unsigned linkMatchType = SelectorChecker::MatchAll, PropertyWhitelistType = Pr opertyWhitelistNone); |
80 }; | 115 }; |
81 | 116 |
82 inline bool operator==(const MatchRanges& a, const MatchRanges& b) | 117 inline bool operator==(const MatchRanges& a, const MatchRanges& b) |
83 { | 118 { |
84 return a.firstUARule == b.firstUARule | 119 return a.UARuleRange() == b.UARuleRange() && a.authorRuleRange() == b.author RuleRange() && a.userRuleRange() == b.userRuleRange(); |
85 && a.lastUARule == b.lastUARule | |
86 && a.firstAuthorRule == b.firstAuthorRule | |
87 && a.lastAuthorRule == b.lastAuthorRule | |
88 && a.firstUserRule == b.firstUserRule | |
89 && a.lastUserRule == b.lastUserRule; | |
90 } | 120 } |
91 | 121 |
92 inline bool operator!=(const MatchRanges& a, const MatchRanges& b) | 122 inline bool operator!=(const MatchRanges& a, const MatchRanges& b) |
93 { | 123 { |
94 return !(a == b); | 124 return !(a == b); |
95 } | 125 } |
96 | 126 |
97 inline bool operator==(const MatchedProperties& a, const MatchedProperties& b) | 127 inline bool operator==(const MatchedProperties& a, const MatchedProperties& b) |
98 { | 128 { |
99 return a.properties == b.properties && a.linkMatchType == b.linkMatchType; | 129 return a.properties == b.properties && a.linkMatchType == b.linkMatchType; |
100 } | 130 } |
101 | 131 |
102 inline bool operator!=(const MatchedProperties& a, const MatchedProperties& b) | 132 inline bool operator!=(const MatchedProperties& a, const MatchedProperties& b) |
103 { | 133 { |
104 return !(a == b); | 134 return !(a == b); |
105 } | 135 } |
106 | 136 |
107 } // namespace WebCore | 137 } // namespace WebCore |
108 | 138 |
109 #endif // MatchResult_h | 139 #endif // MatchResult_h |
OLD | NEW |