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

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

Issue 273843003: [Oilpan]: Make StylePropertySet fully garbage collected. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add comment for ShareableElementData new Created 6 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 | Annotate | Revision Log
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 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #ifndef MatchResult_h 23 #ifndef MatchResult_h
24 #define MatchResult_h 24 #define MatchResult_h
25 25
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 "wtf/RefPtr.h" 29 #include "wtf/RefPtr.h"
29 #include "wtf/Vector.h" 30 #include "wtf/Vector.h"
30 31
31 namespace WebCore { 32 namespace WebCore {
32 33
33 class StylePropertySet; 34 class StylePropertySet;
34 class StyleRule; 35 class StyleRule;
35 36
36 struct RuleRange { 37 struct RuleRange {
37 RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(firstRule Index), lastRuleIndex(lastRuleIndex) { } 38 RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(firstRule Index), lastRuleIndex(lastRuleIndex) { }
38 int& firstRuleIndex; 39 int& firstRuleIndex;
39 int& lastRuleIndex; 40 int& lastRuleIndex;
40 }; 41 };
41 42
42 struct MatchRanges { 43 struct MatchRanges {
43 MatchRanges() : firstUARule(-1), lastUARule(-1), firstAuthorRule(-1), lastAu thorRule(-1), firstUserRule(-1), lastUserRule(-1) { } 44 MatchRanges() : firstUARule(-1), lastUARule(-1), firstAuthorRule(-1), lastAu thorRule(-1), firstUserRule(-1), lastUserRule(-1) { }
44 int firstUARule; 45 int firstUARule;
45 int lastUARule; 46 int lastUARule;
46 int firstAuthorRule; 47 int firstAuthorRule;
47 int lastAuthorRule; 48 int lastAuthorRule;
48 int firstUserRule; 49 int firstUserRule;
49 int lastUserRule; 50 int lastUserRule;
50 RuleRange UARuleRange() { return RuleRange(firstUARule, lastUARule); } 51 RuleRange UARuleRange() { return RuleRange(firstUARule, lastUARule); }
51 RuleRange authorRuleRange() { return RuleRange(firstAuthorRule, lastAuthorRu le); } 52 RuleRange authorRuleRange() { return RuleRange(firstAuthorRule, lastAuthorRu le); }
52 RuleRange userRuleRange() { return RuleRange(firstUserRule, lastUserRule); } 53 RuleRange userRuleRange() { return RuleRange(firstUserRule, lastUserRule); }
53 }; 54 };
54 55
55 struct MatchedProperties { 56 struct MatchedProperties {
57 ALLOW_ONLY_INLINE_ALLOCATION();
58 public:
56 MatchedProperties(); 59 MatchedProperties();
57 ~MatchedProperties(); 60 ~MatchedProperties();
58 61
59 RefPtr<StylePropertySet> properties; 62 void trace(Visitor*);
63
64 RefPtrWillBeWeakMember<StylePropertySet> properties;
65
60 union { 66 union {
61 struct { 67 struct {
62 unsigned linkMatchType : 2; 68 unsigned linkMatchType : 2;
63 unsigned whitelistType : 2; 69 unsigned whitelistType : 2;
64 }; 70 };
65 // Used to make sure all memory is zero-initialized since we compute the hash over the bytes of this object. 71 // Used to make sure all memory is zero-initialized since we compute the hash over the bytes of this object.
66 void* possiblyPaddedMember; 72 void* possiblyPaddedMember;
67 }; 73 };
68 }; 74 };
69 75
76 } // WebCore namespace
77
78 namespace WTF {
Mads Ager (chromium) 2014/06/25 06:31:48 You can use WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCT
wibling-chromium 2014/06/25 09:03:27 Done.
79 template <> struct VectorTraits<WebCore::MatchedProperties> : VectorTraitsBase<W ebCore::MatchedProperties> {
80 static const bool canInitializeWithMemset = true;
81 static const bool canMoveWithMemcpy = true;
82 };
83
84 }
85
86 namespace WebCore {
87
70 class MatchResult { 88 class MatchResult {
71 STACK_ALLOCATED(); 89 STACK_ALLOCATED();
72 public: 90 public:
73 MatchResult() : isCacheable(true) { } 91 MatchResult() : isCacheable(true) { }
74 Vector<MatchedProperties, 64> matchedProperties; 92 WillBeHeapVector<MatchedProperties, 64> matchedProperties;
Mads Ager (chromium) 2014/06/25 06:31:48 In MatchResult you are using the normal tracing of
Erik Corry 2014/06/25 06:58:25 I agree in principle, but it's sort of subtle. Mat
wibling-chromium 2014/06/25 09:03:27 Nice catch. I have changed it be a Member instead.
75 WillBeHeapVector<RawPtrWillBeMember<StyleRule>, 64> matchedRules; 93 WillBeHeapVector<RawPtrWillBeMember<StyleRule>, 64> matchedRules;
76 MatchRanges ranges; 94 MatchRanges ranges;
77 bool isCacheable; 95 bool isCacheable;
78 96
79 void addMatchedProperties(const StylePropertySet* properties, StyleRule* = 0 , unsigned linkMatchType = SelectorChecker::MatchAll, PropertyWhitelistType = Pr opertyWhitelistNone); 97 void addMatchedProperties(const StylePropertySet* properties, StyleRule* = 0 , unsigned linkMatchType = SelectorChecker::MatchAll, PropertyWhitelistType = Pr opertyWhitelistNone);
80 }; 98 };
81 99
82 inline bool operator==(const MatchRanges& a, const MatchRanges& b) 100 inline bool operator==(const MatchRanges& a, const MatchRanges& b)
83 { 101 {
84 return a.firstUARule == b.firstUARule 102 return a.firstUARule == b.firstUARule
(...skipping 15 matching lines...) Expand all
100 } 118 }
101 119
102 inline bool operator!=(const MatchedProperties& a, const MatchedProperties& b) 120 inline bool operator!=(const MatchedProperties& a, const MatchedProperties& b)
103 { 121 {
104 return !(a == b); 122 return !(a == b);
105 } 123 }
106 124
107 } // namespace WebCore 125 } // namespace WebCore
108 126
109 #endif // MatchResult_h 127 #endif // MatchResult_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698