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

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

Issue 1155393002: Refactor matched rule ranges. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
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 15 matching lines...) Expand all
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 "platform/heap/Handle.h" 28 #include "platform/heap/Handle.h"
29 #include "wtf/RefPtr.h" 29 #include "wtf/RefPtr.h"
30 #include "wtf/Vector.h" 30 #include "wtf/Vector.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 class StylePropertySet; 34 class StylePropertySet;
35 35
36 struct RuleRange {
37 RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(firstRule Index), lastRuleIndex(lastRuleIndex) { }
38 int& firstRuleIndex;
39 int& lastRuleIndex;
40 };
41
42 struct MatchRanges {
43 MatchRanges() : firstUARule(-1), lastUARule(-1), firstAuthorRule(-1), lastAu thorRule(-1) { }
44 int firstUARule;
45 int lastUARule;
46 int firstAuthorRule;
47 int lastAuthorRule;
48 RuleRange UARuleRange() { return RuleRange(firstUARule, lastUARule); }
49 RuleRange authorRuleRange() { return RuleRange(firstAuthorRule, lastAuthorRu le); }
50 };
51
52 struct MatchedProperties { 36 struct MatchedProperties {
53 ALLOW_ONLY_INLINE_ALLOCATION(); 37 ALLOW_ONLY_INLINE_ALLOCATION();
54 public: 38 public:
55 MatchedProperties(); 39 MatchedProperties();
56 ~MatchedProperties(); 40 ~MatchedProperties();
57 41
58 DECLARE_TRACE(); 42 DECLARE_TRACE();
59 43
60 RefPtrWillBeMember<StylePropertySet> properties; 44 RefPtrWillBeMember<StylePropertySet> properties;
61 45
62 union { 46 union {
63 struct { 47 struct {
64 unsigned linkMatchType : 2; 48 unsigned linkMatchType : 2;
65 unsigned whitelistType : 2; 49 unsigned whitelistType : 2;
66 } m_types; 50 } m_types;
67 // Used to make sure all memory is zero-initialized since we compute the hash over the bytes of this object. 51 // Used to make sure all memory is zero-initialized since we compute the hash over the bytes of this object.
68 void* possiblyPaddedMember; 52 void* possiblyPaddedMember;
69 }; 53 };
70 }; 54 };
71 55
72 } // namespace blink 56 } // namespace blink
73 57
74 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::MatchedProperties); 58 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::MatchedProperties);
75 59
76 namespace blink { 60 namespace blink {
77 61
78 class MatchResult { 62 class MatchResult {
79 STACK_ALLOCATED(); 63 STACK_ALLOCATED();
80 public: 64 public:
81 MatchResult() : isCacheable(true) { } 65 void addMatchedProperties(const StylePropertySet* properties, unsigned linkM atchType = CSSSelector::MatchAll, PropertyWhitelistType = PropertyWhitelistNone) ;
66
67 int firstRule() const { return 0; }
68 int lastRule() const { return matchedProperties.size() - 1; }
69 int firstUARule() const { return lastUARuleIndex == -1 ? -1 : 0; }
70 int lastUARule() const { return lastUARuleIndex; }
71 int firstAuthorRule() const { return lastUARuleIndex + 1; }
72 int lastAuthorRule() const { return lastRule(); }
73
82 WillBeHeapVector<MatchedProperties, 64> matchedProperties; 74 WillBeHeapVector<MatchedProperties, 64> matchedProperties;
83 MatchRanges ranges; 75 int lastUARuleIndex = -1;
84 bool isCacheable; 76 bool isCacheable = true;
85
86 void addMatchedProperties(const StylePropertySet* properties, unsigned linkM atchType = CSSSelector::MatchAll, PropertyWhitelistType = PropertyWhitelistNone) ;
87 }; 77 };
88 78
89 inline bool operator==(const MatchedProperties& a, const MatchedProperties& b) 79 inline bool operator==(const MatchedProperties& a, const MatchedProperties& b)
90 { 80 {
91 return a.properties == b.properties && a.m_types.linkMatchType == b.m_types. linkMatchType; 81 return a.properties == b.properties && a.m_types.linkMatchType == b.m_types. linkMatchType;
92 } 82 }
93 83
94 inline bool operator!=(const MatchedProperties& a, const MatchedProperties& b) 84 inline bool operator!=(const MatchedProperties& a, const MatchedProperties& b)
95 { 85 {
96 return !(a == b); 86 return !(a == b);
97 } 87 }
98 88
99 } // namespace blink 89 } // namespace blink
100 90
101 #endif // MatchResult_h 91 #endif // MatchResult_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698