| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/html/canvas/CanvasFontCache.h" | 5 #include "core/html/canvas/CanvasFontCache.h" |
| 6 | 6 |
| 7 #include "core/css/parser/CSSParser.h" | 7 #include "core/css/parser/CSSParser.h" |
| 8 #include "core/css/resolver/StyleResolver.h" | 8 #include "core/css/resolver/StyleResolver.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/style/ComputedStyle.h" | 10 #include "core/style/ComputedStyle.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 if (fontValue && | 99 if (fontValue && |
| 100 (fontValue->isInitialValue() || fontValue->isInheritedValue())) | 100 (fontValue->isInitialValue() || fontValue->isInheritedValue())) |
| 101 return nullptr; | 101 return nullptr; |
| 102 m_fetchedFonts.add(fontString, parsedStyle); | 102 m_fetchedFonts.add(fontString, parsedStyle); |
| 103 m_fontLRUList.add(fontString); | 103 m_fontLRUList.add(fontString); |
| 104 // Hard limit is applied here, on the fly, while the soft limit is | 104 // Hard limit is applied here, on the fly, while the soft limit is |
| 105 // applied at the end of the task. | 105 // applied at the end of the task. |
| 106 if (m_fetchedFonts.size() > hardMaxFonts()) { | 106 if (m_fetchedFonts.size() > hardMaxFonts()) { |
| 107 ASSERT(m_fetchedFonts.size() == hardMaxFonts() + 1); | 107 ASSERT(m_fetchedFonts.size() == hardMaxFonts() + 1); |
| 108 ASSERT(m_fontLRUList.size() == hardMaxFonts() + 1); | 108 ASSERT(m_fontLRUList.size() == hardMaxFonts() + 1); |
| 109 m_fetchedFonts.remove(m_fontLRUList.first()); | 109 m_fetchedFonts.erase(m_fontLRUList.first()); |
| 110 m_fontsResolvedUsingDefaultStyle.remove(m_fontLRUList.first()); | 110 m_fontsResolvedUsingDefaultStyle.erase(m_fontLRUList.first()); |
| 111 m_fontLRUList.removeFirst(); | 111 m_fontLRUList.removeFirst(); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 schedulePruningIfNeeded(); | 114 schedulePruningIfNeeded(); |
| 115 | 115 |
| 116 return parsedStyle; | 116 return parsedStyle; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void CanvasFontCache::didProcessTask() { | 119 void CanvasFontCache::didProcessTask() { |
| 120 ASSERT(m_pruningScheduled); | 120 ASSERT(m_pruningScheduled); |
| 121 ASSERT(m_mainCachePurgePreventer); | 121 ASSERT(m_mainCachePurgePreventer); |
| 122 while (m_fetchedFonts.size() > maxFonts()) { | 122 while (m_fetchedFonts.size() > maxFonts()) { |
| 123 m_fetchedFonts.remove(m_fontLRUList.first()); | 123 m_fetchedFonts.erase(m_fontLRUList.first()); |
| 124 m_fontsResolvedUsingDefaultStyle.remove(m_fontLRUList.first()); | 124 m_fontsResolvedUsingDefaultStyle.erase(m_fontLRUList.first()); |
| 125 m_fontLRUList.removeFirst(); | 125 m_fontLRUList.removeFirst(); |
| 126 } | 126 } |
| 127 m_mainCachePurgePreventer.reset(); | 127 m_mainCachePurgePreventer.reset(); |
| 128 Platform::current()->currentThread()->removeTaskObserver(this); | 128 Platform::current()->currentThread()->removeTaskObserver(this); |
| 129 m_pruningScheduled = false; | 129 m_pruningScheduled = false; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void CanvasFontCache::schedulePruningIfNeeded() { | 132 void CanvasFontCache::schedulePruningIfNeeded() { |
| 133 if (m_pruningScheduled) | 133 if (m_pruningScheduled) |
| 134 return; | 134 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 147 m_fontLRUList.clear(); | 147 m_fontLRUList.clear(); |
| 148 m_fontsResolvedUsingDefaultStyle.clear(); | 148 m_fontsResolvedUsingDefaultStyle.clear(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 DEFINE_TRACE(CanvasFontCache) { | 151 DEFINE_TRACE(CanvasFontCache) { |
| 152 visitor->trace(m_fetchedFonts); | 152 visitor->trace(m_fetchedFonts); |
| 153 visitor->trace(m_document); | 153 visitor->trace(m_document); |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace blink | 156 } // namespace blink |
| OLD | NEW |