| OLD | NEW |
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 Vector<MatchedProperties> matchedProperties; | 42 Vector<MatchedProperties> matchedProperties; |
| 43 MatchRanges ranges; | 43 MatchRanges ranges; |
| 44 RefPtr<RenderStyle> renderStyle; | 44 RefPtr<RenderStyle> renderStyle; |
| 45 RefPtr<RenderStyle> parentRenderStyle; | 45 RefPtr<RenderStyle> parentRenderStyle; |
| 46 | 46 |
| 47 void set(const RenderStyle*, const RenderStyle* parentStyle, const MatchResu
lt&); | 47 void set(const RenderStyle*, const RenderStyle* parentStyle, const MatchResu
lt&); |
| 48 void clear(); | 48 void clear(); |
| 49 void trace(Visitor* visitor) { visitor->trace(matchedProperties); } | 49 void trace(Visitor* visitor) { visitor->trace(matchedProperties); } |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 // Specialize the HashTraits for CachedMatchedProperties to check for dead | |
| 53 // entries in the MatchedPropertiesCache. | |
| 54 #if ENABLE(OILPAN) | |
| 55 struct CachedMatchedPropertiesHashTraits : HashTraits<Member<CachedMatchedProper
ties> > { | |
| 56 static const WTF::WeakHandlingFlag weakHandlingFlag = WTF::WeakHandlingInCol
lections; | |
| 57 static bool traceInCollection(Visitor*, Member<CachedMatchedProperties>&, WT
F::ShouldWeakPointersBeMarkedStrongly); | |
| 58 }; | |
| 59 #endif | |
| 60 | |
| 61 class MatchedPropertiesCache { | 52 class MatchedPropertiesCache { |
| 62 DISALLOW_ALLOCATION(); | 53 DISALLOW_ALLOCATION(); |
| 63 WTF_MAKE_NONCOPYABLE(MatchedPropertiesCache); | 54 WTF_MAKE_NONCOPYABLE(MatchedPropertiesCache); |
| 64 public: | 55 public: |
| 65 MatchedPropertiesCache(); | 56 MatchedPropertiesCache(); |
| 66 | 57 |
| 67 const CachedMatchedProperties* find(unsigned hash, const StyleResolverState&
, const MatchResult&); | 58 const CachedMatchedProperties* find(unsigned hash, const StyleResolverState&
, const MatchResult&); |
| 68 void add(const RenderStyle*, const RenderStyle* parentStyle, unsigned hash,
const MatchResult&); | 59 void add(const RenderStyle*, const RenderStyle* parentStyle, unsigned hash,
const MatchResult&); |
| 69 | 60 |
| 70 void clear(); | 61 void clear(); |
| 71 void clearViewportDependent(); | 62 void clearViewportDependent(); |
| 72 | 63 |
| 73 static bool isCacheable(const Element*, const RenderStyle*, const RenderStyl
e* parentStyle); | 64 static bool isCacheable(const Element*, const RenderStyle*, const RenderStyl
e* parentStyle); |
| 74 | 65 |
| 75 void trace(Visitor*); | 66 void trace(Visitor*); |
| 76 | 67 |
| 77 private: | 68 private: |
| 78 #if ENABLE(OILPAN) | |
| 79 typedef HeapHashMap<unsigned, Member<CachedMatchedProperties>, DefaultHash<u
nsigned>::Hash, HashTraits<unsigned>, CachedMatchedPropertiesHashTraits > Cache; | |
| 80 #else | |
| 81 // Every N additions to the matched declaration cache trigger a sweep where
entries holding | 69 // Every N additions to the matched declaration cache trigger a sweep where
entries holding |
| 82 // the last reference to a style declaration are garbage collected. | 70 // the last reference to a style declaration are garbage collected. |
| 83 void sweep(Timer<MatchedPropertiesCache>*); | 71 void sweep(Timer<MatchedPropertiesCache>*); |
| 84 | 72 |
| 85 unsigned m_additionsSinceLastSweep; | 73 unsigned m_additionsSinceLastSweep; |
| 86 | 74 |
| 87 typedef HashMap<unsigned, OwnPtr<CachedMatchedProperties> > Cache; | 75 typedef HashMap<unsigned, OwnPtr<CachedMatchedProperties> > Cache; |
| 88 Timer<MatchedPropertiesCache> m_sweepTimer; | 76 Timer<MatchedPropertiesCache> m_sweepTimer; |
| 89 #endif | |
| 90 Cache m_cache; | 77 Cache m_cache; |
| 91 }; | 78 }; |
| 92 | 79 |
| 93 } | 80 } |
| 94 | 81 |
| 95 #endif | 82 #endif |
| OLD | NEW |