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

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

Issue 273843003: [Oilpan]: Make StylePropertySet fully garbage collected. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 MatchedPropertiesCache_h 23 #ifndef MatchedPropertiesCache_h
24 #define MatchedPropertiesCache_h 24 #define MatchedPropertiesCache_h
25 25
26 #include "core/css/resolver/MatchResult.h" 26 #include "core/css/resolver/MatchResult.h"
27 27
28 #include "platform/Timer.h" 28 #include "platform/Timer.h"
29 #include "platform/heap/Handle.h"
29 #include "wtf/Forward.h" 30 #include "wtf/Forward.h"
30 #include "wtf/HashMap.h" 31 #include "wtf/HashMap.h"
31 #include "wtf/Noncopyable.h" 32 #include "wtf/Noncopyable.h"
32 33
33 namespace WebCore { 34 namespace WebCore {
34 35
35 class RenderStyle; 36 class RenderStyle;
36 class StyleResolverState; 37 class StyleResolverState;
37 38
38 struct CachedMatchedProperties { 39 struct CachedMatchedProperties : public NoBaseWillBeGarbageCollectedFinalized<Ca chedMatchedProperties> {
haraken 2014/05/08 11:43:45 Nit: struct => class
wibling-chromium 2014/05/08 12:38:55 Done.
39 Vector<MatchedProperties> matchedProperties; 40
41 public:
42 WillBeHeapVector<MatchedProperties> matchedProperties;
40 MatchRanges ranges; 43 MatchRanges ranges;
41 RefPtr<RenderStyle> renderStyle; 44 RefPtr<RenderStyle> renderStyle;
42 RefPtr<RenderStyle> parentRenderStyle; 45 RefPtr<RenderStyle> parentRenderStyle;
43 46
44 void set(const RenderStyle*, const RenderStyle* parentStyle, const MatchResu lt&); 47 void set(const RenderStyle*, const RenderStyle* parentStyle, const MatchResu lt&);
45 void clear(); 48 void clear();
49 void trace(Visitor* visitor) { visitor->trace(matchedProperties); }
46 }; 50 };
47 51
48 class MatchedPropertiesCache { 52 class MatchedPropertiesCache {
53 DISALLOW_ALLOCATION();
49 WTF_MAKE_NONCOPYABLE(MatchedPropertiesCache); 54 WTF_MAKE_NONCOPYABLE(MatchedPropertiesCache);
50 public: 55 public:
51 MatchedPropertiesCache(); 56 MatchedPropertiesCache();
52 57
53 const CachedMatchedProperties* find(unsigned hash, const StyleResolverState& , const MatchResult&); 58 const CachedMatchedProperties* find(unsigned hash, const StyleResolverState& , const MatchResult&);
54 void add(const RenderStyle*, const RenderStyle* parentStyle, unsigned hash, const MatchResult&); 59 void add(const RenderStyle*, const RenderStyle* parentStyle, unsigned hash, const MatchResult&);
55 60
56 void clear(); 61 void clear();
57 void clearViewportDependent(); 62 void clearViewportDependent();
58 63
59 static bool isCacheable(const Element*, const RenderStyle*, const RenderStyl e* parentStyle); 64 static bool isCacheable(const Element*, const RenderStyle*, const RenderStyl e* parentStyle);
60 65
66 void trace(Visitor*);
67 void processWeakMembers(Visitor*);
68
61 private: 69 private:
62 // Every N additions to the matched declaration cache trigger a sweep where entries holding 70 // Every N additions to the matched declaration cache trigger a sweep where entries holding
63 // the last reference to a style declaration are garbage collected. 71 // the last reference to a style declaration are garbage collected.
64 void sweep(Timer<MatchedPropertiesCache>*); 72 void sweep(Timer<MatchedPropertiesCache>*);
65 73
66 unsigned m_additionsSinceLastSweep; 74 unsigned m_additionsSinceLastSweep;
67 75
68 typedef HashMap<unsigned, OwnPtr<CachedMatchedProperties> > Cache; 76 typedef WillBeHeapHashMap<unsigned, OwnPtrWillBeMember<CachedMatchedProperti es> > Cache;
69 Cache m_cache; 77 Cache m_cache;
78 Timer<MatchedPropertiesCache> m_sweepTimer;
70 79
71 Timer<MatchedPropertiesCache> m_sweepTimer; 80 #if ENABLE(OILPAN)
81 bool m_cacheNeedsCleaning;
82 #endif
72 }; 83 };
73 84
74 } 85 }
75 86
76 #endif 87 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698