| 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 15 matching lines...) Expand all Loading... |
| 26 #include "core/css/StylePropertySet.h" | 26 #include "core/css/StylePropertySet.h" |
| 27 #include "core/css/resolver/MatchResult.h" | 27 #include "core/css/resolver/MatchResult.h" |
| 28 #include "platform/Timer.h" | 28 #include "platform/Timer.h" |
| 29 #include "platform/heap/Handle.h" | 29 #include "platform/heap/Handle.h" |
| 30 #include "wtf/Forward.h" | 30 #include "wtf/Forward.h" |
| 31 #include "wtf/HashMap.h" | 31 #include "wtf/HashMap.h" |
| 32 #include "wtf/Noncopyable.h" | 32 #include "wtf/Noncopyable.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class LayoutStyle; | 36 class ComputedStyle; |
| 37 class StyleResolverState; | 37 class StyleResolverState; |
| 38 | 38 |
| 39 class CachedMatchedProperties final : public NoBaseWillBeGarbageCollectedFinaliz
ed<CachedMatchedProperties> { | 39 class CachedMatchedProperties final : public NoBaseWillBeGarbageCollectedFinaliz
ed<CachedMatchedProperties> { |
| 40 | 40 |
| 41 public: | 41 public: |
| 42 WillBeHeapVector<MatchedProperties> matchedProperties; | 42 WillBeHeapVector<MatchedProperties> matchedProperties; |
| 43 MatchRanges ranges; | 43 MatchRanges ranges; |
| 44 RefPtr<LayoutStyle> layoutStyle; | 44 RefPtr<ComputedStyle> computedStyle; |
| 45 RefPtr<LayoutStyle> parentLayoutStyle; | 45 RefPtr<ComputedStyle> parentComputedStyle; |
| 46 | 46 |
| 47 void set(const LayoutStyle&, const LayoutStyle& parentStyle, const MatchResu
lt&); | 47 void set(const ComputedStyle&, const ComputedStyle& parentStyle, const Match
Result&); |
| 48 void clear(); | 48 void clear(); |
| 49 DEFINE_INLINE_TRACE() { visitor->trace(matchedProperties); } | 49 DEFINE_INLINE_TRACE() { visitor->trace(matchedProperties); } |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 // Specialize the HashTraits for CachedMatchedProperties to check for dead | 52 // Specialize the HashTraits for CachedMatchedProperties to check for dead |
| 53 // entries in the MatchedPropertiesCache. | 53 // entries in the MatchedPropertiesCache. |
| 54 #if ENABLE(OILPAN) | 54 #if ENABLE(OILPAN) |
| 55 struct CachedMatchedPropertiesHashTraits : HashTraits<Member<CachedMatchedProper
ties>> { | 55 struct CachedMatchedPropertiesHashTraits : HashTraits<Member<CachedMatchedProper
ties>> { |
| 56 static const WTF::WeakHandlingFlag weakHandlingFlag = WTF::WeakHandlingInCol
lections; | 56 static const WTF::WeakHandlingFlag weakHandlingFlag = WTF::WeakHandlingInCol
lections; |
| 57 | 57 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 85 }; | 85 }; |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 class MatchedPropertiesCache { | 88 class MatchedPropertiesCache { |
| 89 DISALLOW_ALLOCATION(); | 89 DISALLOW_ALLOCATION(); |
| 90 WTF_MAKE_NONCOPYABLE(MatchedPropertiesCache); | 90 WTF_MAKE_NONCOPYABLE(MatchedPropertiesCache); |
| 91 public: | 91 public: |
| 92 MatchedPropertiesCache(); | 92 MatchedPropertiesCache(); |
| 93 | 93 |
| 94 const CachedMatchedProperties* find(unsigned hash, const StyleResolverState&
, const MatchResult&); | 94 const CachedMatchedProperties* find(unsigned hash, const StyleResolverState&
, const MatchResult&); |
| 95 void add(const LayoutStyle&, const LayoutStyle& parentStyle, unsigned hash,
const MatchResult&); | 95 void add(const ComputedStyle&, const ComputedStyle& parentStyle, unsigned ha
sh, const MatchResult&); |
| 96 | 96 |
| 97 void clear(); | 97 void clear(); |
| 98 void clearViewportDependent(); | 98 void clearViewportDependent(); |
| 99 | 99 |
| 100 static bool isCacheable(const Element*, const LayoutStyle&, const LayoutStyl
e& parentStyle); | 100 static bool isCacheable(const Element*, const ComputedStyle&, const Computed
Style& parentStyle); |
| 101 | 101 |
| 102 DECLARE_TRACE(); | 102 DECLARE_TRACE(); |
| 103 | 103 |
| 104 private: | 104 private: |
| 105 #if ENABLE(OILPAN) | 105 #if ENABLE(OILPAN) |
| 106 typedef HeapHashMap<unsigned, Member<CachedMatchedProperties>, DefaultHash<u
nsigned>::Hash, HashTraits<unsigned>, CachedMatchedPropertiesHashTraits > Cache; | 106 typedef HeapHashMap<unsigned, Member<CachedMatchedProperties>, DefaultHash<u
nsigned>::Hash, HashTraits<unsigned>, CachedMatchedPropertiesHashTraits > Cache; |
| 107 #else | 107 #else |
| 108 // Every N additions to the matched declaration cache trigger a sweep where
entries holding | 108 // Every N additions to the matched declaration cache trigger a sweep where
entries holding |
| 109 // the last reference to a style declaration are garbage collected. | 109 // the last reference to a style declaration are garbage collected. |
| 110 void sweep(Timer<MatchedPropertiesCache>*); | 110 void sweep(Timer<MatchedPropertiesCache>*); |
| 111 | 111 |
| 112 unsigned m_additionsSinceLastSweep; | 112 unsigned m_additionsSinceLastSweep; |
| 113 | 113 |
| 114 typedef HashMap<unsigned, OwnPtr<CachedMatchedProperties>> Cache; | 114 typedef HashMap<unsigned, OwnPtr<CachedMatchedProperties>> Cache; |
| 115 Timer<MatchedPropertiesCache> m_sweepTimer; | 115 Timer<MatchedPropertiesCache> m_sweepTimer; |
| 116 #endif | 116 #endif |
| 117 Cache m_cache; | 117 Cache m_cache; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } | 120 } |
| 121 | 121 |
| 122 #endif | 122 #endif |
| OLD | NEW |