Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(636)

Side by Side Diff: Source/core/css/resolver/MatchResult.h

Issue 1134173002: Get rid of TreeBoundaryCrossingRules. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Missing important UA rules. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/TreeBoundaryCrossingRules.cpp ('k') | Source/core/css/resolver/MatchResult.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 void* possiblyPaddedMember; 52 void* possiblyPaddedMember;
53 }; 53 };
54 }; 54 };
55 55
56 } // namespace blink 56 } // namespace blink
57 57
58 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::MatchedProperties); 58 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::MatchedProperties);
59 59
60 namespace blink { 60 namespace blink {
61 61
62 using MatchedPropertiesVector = WillBeHeapVector<MatchedProperties, 64>;
63
64 class MatchedPropertiesRange {
65 public:
66 MatchedPropertiesRange(MatchedPropertiesVector::const_iterator begin, Matche dPropertiesVector::const_iterator end)
67 : m_begin(begin)
68 , m_end(end)
69 {
70 }
71
72 MatchedPropertiesVector::const_iterator begin() const { return m_begin; }
73 MatchedPropertiesVector::const_iterator end() const { return m_end; }
74
75 private:
76 MatchedPropertiesVector::const_iterator m_begin;
77 MatchedPropertiesVector::const_iterator m_end;
78 };
79
62 class MatchResult { 80 class MatchResult {
63 STACK_ALLOCATED(); 81 STACK_ALLOCATED();
64 public: 82 public:
83 MatchResult() { m_rangeEnd.append(0); /* Alway add a UA range */ }
84
65 void addMatchedProperties(const StylePropertySet* properties, unsigned linkM atchType = CSSSelector::MatchAll, PropertyWhitelistType = PropertyWhitelistNone) ; 85 void addMatchedProperties(const StylePropertySet* properties, unsigned linkM atchType = CSSSelector::MatchAll, PropertyWhitelistType = PropertyWhitelistNone) ;
86 bool hasMatchedProperties() const { return m_matchedProperties.size(); }
66 87
67 unsigned begin() const { return 0; } 88 void closeOriginOrScope(bool isUAOrigin = false);
68 unsigned end() const { return matchedProperties.size(); }
69 unsigned beginUA() const { return 0; }
70 unsigned endUA() const { return uaEnd; }
71 unsigned beginAuthor() const { return uaEnd; }
72 unsigned endAuthor() const { return matchedProperties.size(); }
73 89
74 WillBeHeapVector<MatchedProperties, 64> matchedProperties; 90 void setIsCacheable(bool cacheable) { m_isCacheable = cacheable; }
75 unsigned uaEnd = 0; 91 bool isCacheable() const { return m_isCacheable; }
76 bool isCacheable = true; 92
93 MatchedPropertiesRange allRules() const { return MatchedPropertiesRange(m_ma tchedProperties.begin(), m_matchedProperties.end()); }
94 MatchedPropertiesRange uaRules() const { return MatchedPropertiesRange(m_mat chedProperties.begin(), m_matchedProperties.begin() + m_rangeEnd.first()); }
95 MatchedPropertiesRange authorRules() const { return MatchedPropertiesRange(m _matchedProperties.begin() + m_rangeEnd.first(), m_matchedProperties.end()); }
96
97 const MatchedPropertiesVector& matchedProperties() const { return m_matchedP roperties; }
98
99 private:
100 friend class ImportantAuthorRanges;
101 friend class ImportantAuthorRangeIterator;
102
103 MatchedPropertiesVector m_matchedProperties;
104 Vector<unsigned, 16> m_rangeEnd;
105 bool m_isCacheable = true;
106 };
107
108 class ImportantAuthorRangeIterator {
109 public:
110 ImportantAuthorRangeIterator(const MatchResult& result, unsigned index)
111 : m_result(result)
112 , m_index(index) { }
113
114 MatchedPropertiesRange operator*() const
115 {
116 ASSERT(m_index);
117 return MatchedPropertiesRange(m_result.m_matchedProperties.begin() + m_r esult.m_rangeEnd[m_index - 1], m_result.m_matchedProperties.begin() + m_result.m _rangeEnd[m_index]);
118 }
119
120 ImportantAuthorRangeIterator& operator++()
121 {
122 ASSERT(m_index > 0);
123 --m_index;
124 return *this;
125 }
126
127 bool operator!=(const ImportantAuthorRangeIterator& other) const { return m_ index != other.m_index || &m_result != &other.m_result; }
128
129 private:
130 const MatchResult& m_result;
131 unsigned m_index;
132 };
133
134 class ImportantAuthorRanges {
135 public:
136 explicit ImportantAuthorRanges(const MatchResult& result) : m_result(result) { }
137
138 ImportantAuthorRangeIterator begin() const { return ImportantAuthorRangeIter ator(m_result, m_result.m_rangeEnd.size() - 1); }
139 ImportantAuthorRangeIterator end() const { return ImportantAuthorRangeIterat or(m_result, 0); }
140
141 private:
142 const MatchResult& m_result;
77 }; 143 };
78 144
79 inline bool operator==(const MatchedProperties& a, const MatchedProperties& b) 145 inline bool operator==(const MatchedProperties& a, const MatchedProperties& b)
80 { 146 {
81 return a.properties == b.properties && a.m_types.linkMatchType == b.m_types. linkMatchType; 147 return a.properties == b.properties && a.m_types.linkMatchType == b.m_types. linkMatchType;
82 } 148 }
83 149
84 inline bool operator!=(const MatchedProperties& a, const MatchedProperties& b) 150 inline bool operator!=(const MatchedProperties& a, const MatchedProperties& b)
85 { 151 {
86 return !(a == b); 152 return !(a == b);
87 } 153 }
88 154
89 } // namespace blink 155 } // namespace blink
90 156
91 #endif // MatchResult_h 157 #endif // MatchResult_h
OLDNEW
« no previous file with comments | « Source/core/css/TreeBoundaryCrossingRules.cpp ('k') | Source/core/css/resolver/MatchResult.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698