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

Side by Side Diff: third_party/WebKit/Source/core/html/canvas/CanvasFontCache.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
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"
11 #include "platform/fonts/FontCache.h" 11 #include "platform/fonts/FontCache.h"
12 #include "public/platform/Platform.h" 12 #include "public/platform/Platform.h"
13 #include "wtf/PtrUtil.h"
14 13
15 namespace { 14 namespace {
16 15
17 const unsigned CanvasFontCacheMaxFonts = 50; 16 const unsigned CanvasFontCacheMaxFonts = 50;
18 const unsigned CanvasFontCacheHardMaxFonts = 250; 17 const unsigned CanvasFontCacheHardMaxFonts = 250;
19 const unsigned CanvasFontCacheHiddenMaxFonts = 1; 18 const unsigned CanvasFontCacheHiddenMaxFonts = 1;
20 const int defaultFontSize = 10; 19 const int defaultFontSize = 10;
21 const char defaultFontFamily[] = "sans-serif"; 20 const char defaultFontFamily[] = "sans-serif";
22 21
23 } 22 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 m_mainCachePurgePreventer.reset(); 127 m_mainCachePurgePreventer.reset();
129 Platform::current()->currentThread()->removeTaskObserver(this); 128 Platform::current()->currentThread()->removeTaskObserver(this);
130 m_pruningScheduled = false; 129 m_pruningScheduled = false;
131 } 130 }
132 131
133 void CanvasFontCache::schedulePruningIfNeeded() 132 void CanvasFontCache::schedulePruningIfNeeded()
134 { 133 {
135 if (m_pruningScheduled) 134 if (m_pruningScheduled)
136 return; 135 return;
137 ASSERT(!m_mainCachePurgePreventer); 136 ASSERT(!m_mainCachePurgePreventer);
138 m_mainCachePurgePreventer = wrapUnique(new FontCachePurgePreventer); 137 m_mainCachePurgePreventer = adoptPtr(new FontCachePurgePreventer);
139 Platform::current()->currentThread()->addTaskObserver(this); 138 Platform::current()->currentThread()->addTaskObserver(this);
140 m_pruningScheduled = true; 139 m_pruningScheduled = true;
141 } 140 }
142 141
143 bool CanvasFontCache::isInCache(const String& fontString) 142 bool CanvasFontCache::isInCache(const String& fontString)
144 { 143 {
145 return m_fetchedFonts.find(fontString) != m_fetchedFonts.end(); 144 return m_fetchedFonts.find(fontString) != m_fetchedFonts.end();
146 } 145 }
147 146
148 void CanvasFontCache::pruneAll() 147 void CanvasFontCache::pruneAll()
149 { 148 {
150 m_fetchedFonts.clear(); 149 m_fetchedFonts.clear();
151 m_fontLRUList.clear(); 150 m_fontLRUList.clear();
152 m_fontsResolvedUsingDefaultStyle.clear(); 151 m_fontsResolvedUsingDefaultStyle.clear();
153 } 152 }
154 153
155 DEFINE_TRACE(CanvasFontCache) 154 DEFINE_TRACE(CanvasFontCache)
156 { 155 {
157 visitor->trace(m_fetchedFonts); 156 visitor->trace(m_fetchedFonts);
158 visitor->trace(m_document); 157 visitor->trace(m_document);
159 } 158 }
160 159
161 } // namespace blink 160 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698