Index: Source/core/css/resolver/MatchResult.h |
diff --git a/Source/core/css/resolver/MatchResult.h b/Source/core/css/resolver/MatchResult.h |
index 25d9b91900a50be0e24b2af3e7725e6e291714ea..a3e537493c60753f9a11e870f1f4860da57f1883 100644 |
--- a/Source/core/css/resolver/MatchResult.h |
+++ b/Source/core/css/resolver/MatchResult.h |
@@ -33,23 +33,58 @@ namespace WebCore { |
class StylePropertySet; |
class StyleRule; |
-struct RuleRange { |
- RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(firstRuleIndex), lastRuleIndex(lastRuleIndex) { } |
- int& firstRuleIndex; |
- int& lastRuleIndex; |
+class RuleRange { |
+public: |
+ RuleRange() : m_firstRuleIndex(-1), m_lastRuleIndex(-1) { } |
+ RuleRange(int firstRuleIndex, int lastRuleIndex) : m_firstRuleIndex(firstRuleIndex), m_lastRuleIndex(lastRuleIndex) { } |
esprehn
2014/03/27 08:41:59
The initializer should be on a different line.
Ru
|
+ |
+ int first() const { return m_firstRuleIndex; } |
+ int last() const { return m_lastRuleIndex; } |
+ |
+ bool collapsed() const { return m_firstRuleIndex == -1; } |
+ |
+ void setLast(int position) { m_lastRuleIndex = position; } |
+ |
+ void shiftLast(int position) |
+ { |
+ m_lastRuleIndex = position; |
esprehn
2014/03/27 08:41:59
This doesn't seem to shift the last, it seems to a
|
+ if (m_firstRuleIndex == -1) |
+ m_firstRuleIndex = position; |
+ } |
+ |
+ void shiftLastByOne() |
+ { |
+ ++m_lastRuleIndex; |
+ if (m_firstRuleIndex == -1) |
+ m_firstRuleIndex = m_lastRuleIndex; |
+ } |
+ |
+private: |
+ int m_firstRuleIndex; |
+ int m_lastRuleIndex; |
}; |
-struct MatchRanges { |
- MatchRanges() : firstUARule(-1), lastUARule(-1), firstAuthorRule(-1), lastAuthorRule(-1), firstUserRule(-1), lastUserRule(-1) { } |
- int firstUARule; |
- int lastUARule; |
- int firstAuthorRule; |
- int lastAuthorRule; |
- int firstUserRule; |
- int lastUserRule; |
- RuleRange UARuleRange() { return RuleRange(firstUARule, lastUARule); } |
- RuleRange authorRuleRange() { return RuleRange(firstAuthorRule, lastAuthorRule); } |
- RuleRange userRuleRange() { return RuleRange(firstUserRule, lastUserRule); } |
+inline bool operator==(const RuleRange& a, const RuleRange& b) |
+{ |
+ return a.first() == b.first() && a.last() == b.last(); |
+} |
+ |
+class MatchRanges { |
+public: |
+ MatchRanges() { } |
esprehn
2014/03/27 08:41:59
Leave off the default constructor, the compiler wi
|
+ |
+ RuleRange& UARuleRange() { return m_uaRuleRange; } |
esprehn
2014/03/27 08:41:59
ua should be lower case.
|
+ RuleRange& authorRuleRange() { return m_authorRuleRange; } |
+ RuleRange& userRuleRange() { return m_userRuleRange; } |
+ |
+ const RuleRange& UARuleRange() const { return m_uaRuleRange; } |
esprehn
2014/03/27 08:41:59
ditto
|
+ const RuleRange& authorRuleRange() const { return m_authorRuleRange; } |
+ const RuleRange& userRuleRange() const { return m_userRuleRange; } |
+ |
+private: |
+ RuleRange m_uaRuleRange; |
+ RuleRange m_authorRuleRange; |
+ RuleRange m_userRuleRange; |
}; |
struct MatchedProperties { |
@@ -81,12 +116,7 @@ public: |
inline bool operator==(const MatchRanges& a, const MatchRanges& b) |
{ |
- return a.firstUARule == b.firstUARule |
- && a.lastUARule == b.lastUARule |
- && a.firstAuthorRule == b.firstAuthorRule |
- && a.lastAuthorRule == b.lastAuthorRule |
- && a.firstUserRule == b.firstUserRule |
- && a.lastUserRule == b.lastUserRule; |
+ return a.UARuleRange() == b.UARuleRange() && a.authorRuleRange() == b.authorRuleRange() && a.userRuleRange() == b.userRuleRange(); |
} |
inline bool operator!=(const MatchRanges& a, const MatchRanges& b) |