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

Side by Side Diff: Source/core/css/FontFaceCache.cpp

Issue 230303002: Revert of [Oilpan]: Moving the FontSelector/FontCacheClient, CSSSegmentedFontFace, and FontFaceCache to the o… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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
« no previous file with comments | « Source/core/css/FontFaceCache.h ('k') | Source/core/css/resolver/FontBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 RefPtr<FontFace> fontFace = prpFontFace; 51 RefPtr<FontFace> fontFace = prpFontFace;
52 if (!m_styleRuleToFontFace.add(fontFaceRule, fontFace).isNewEntry) 52 if (!m_styleRuleToFontFace.add(fontFaceRule, fontFace).isNewEntry)
53 return; 53 return;
54 addFontFace(cssFontSelector, fontFace, true); 54 addFontFace(cssFontSelector, fontFace, true);
55 } 55 }
56 56
57 void FontFaceCache::addFontFace(CSSFontSelector* cssFontSelector, PassRefPtr<Fon tFace> prpFontFace, bool cssConnected) 57 void FontFaceCache::addFontFace(CSSFontSelector* cssFontSelector, PassRefPtr<Fon tFace> prpFontFace, bool cssConnected)
58 { 58 {
59 RefPtr<FontFace> fontFace = prpFontFace; 59 RefPtr<FontFace> fontFace = prpFontFace;
60 60
61 TraitsMap* familyFontFaces = m_fontFaces.get(fontFace->family()); 61 OwnPtr<TraitsMap>& familyFontFaces = m_fontFaces.add(fontFace->family(), nul lptr).storedValue->value;
62 if (!familyFontFaces) 62 if (!familyFontFaces)
63 familyFontFaces = m_fontFaces.set(fontFace->family(), adoptPtrWillBeNoop (new TraitsMap)).storedValue->value.get(); 63 familyFontFaces = adoptPtr(new TraitsMap);
64 64
65 CSSSegmentedFontFace* segmentedFontFace = familyFontFaces->get(fontFace->tra its().mask()); 65 RefPtr<CSSSegmentedFontFace>& segmentedFontFace = familyFontFaces->add(fontF ace->traits().mask(), nullptr).storedValue->value;
66 if (!segmentedFontFace) 66 if (!segmentedFontFace)
67 segmentedFontFace = familyFontFaces->set(fontFace->traits().mask(), CSSS egmentedFontFace::create(cssFontSelector, fontFace->traits())).storedValue->valu e.get(); 67 segmentedFontFace = CSSSegmentedFontFace::create(cssFontSelector, fontFa ce->traits());
68 68
69 segmentedFontFace->addFontFace(fontFace, cssConnected); 69 segmentedFontFace->addFontFace(fontFace, cssConnected);
70 if (cssConnected) 70 if (cssConnected)
71 m_cssConnectedFontFaces.add(fontFace); 71 m_cssConnectedFontFaces.add(fontFace);
72 72
73 ++m_version; 73 ++m_version;
74 } 74 }
75 75
76 void FontFaceCache::remove(const StyleRuleFontFace* fontFaceRule) 76 void FontFaceCache::remove(const StyleRuleFontFace* fontFaceRule)
77 { 77 {
78 StyleRuleToFontFace::iterator it = m_styleRuleToFontFace.find(fontFaceRule); 78 StyleRuleToFontFace::iterator it = m_styleRuleToFontFace.find(fontFaceRule);
79 if (it != m_styleRuleToFontFace.end()) { 79 if (it != m_styleRuleToFontFace.end()) {
80 removeFontFace(it->value.get(), true); 80 removeFontFace(it->value.get(), true);
81 m_styleRuleToFontFace.remove(it); 81 m_styleRuleToFontFace.remove(it);
82 } 82 }
83 } 83 }
84 84
85 void FontFaceCache::removeFontFace(FontFace* fontFace, bool cssConnected) 85 void FontFaceCache::removeFontFace(FontFace* fontFace, bool cssConnected)
86 { 86 {
87 FamilyToTraitsMap::iterator fontFacesIter = m_fontFaces.find(fontFace->famil y()); 87 FamilyToTraitsMap::iterator fontFacesIter = m_fontFaces.find(fontFace->famil y());
88 if (fontFacesIter == m_fontFaces.end()) 88 if (fontFacesIter == m_fontFaces.end())
89 return; 89 return;
90 TraitsMap* familyFontFaces = fontFacesIter->value.get(); 90 TraitsMap* familyFontFaces = fontFacesIter->value.get();
91 91
92 TraitsMap::iterator familyFontFacesIter = familyFontFaces->find(fontFace->tr aits().mask()); 92 TraitsMap::iterator familyFontFacesIter = familyFontFaces->find(fontFace->tr aits().mask());
93 if (familyFontFacesIter == familyFontFaces->end()) 93 if (familyFontFacesIter == familyFontFaces->end())
94 return; 94 return;
95 RefPtrWillBeRawPtr<CSSSegmentedFontFace> segmentedFontFace = familyFontFaces Iter->value; 95 RefPtr<CSSSegmentedFontFace> segmentedFontFace = familyFontFacesIter->value;
96 96
97 segmentedFontFace->removeFontFace(fontFace); 97 segmentedFontFace->removeFontFace(fontFace);
98 if (segmentedFontFace->isEmpty()) { 98 if (segmentedFontFace->isEmpty()) {
99 familyFontFaces->remove(familyFontFacesIter); 99 familyFontFaces->remove(familyFontFacesIter);
100 if (familyFontFaces->isEmpty()) 100 if (familyFontFaces->isEmpty())
101 m_fontFaces.remove(fontFacesIter); 101 m_fontFaces.remove(fontFacesIter);
102 } 102 }
103 m_fonts.clear(); 103 m_fonts.clear();
104 if (cssConnected) 104 if (cssConnected)
105 m_cssConnectedFontFaces.remove(fontFace); 105 m_cssConnectedFontFaces.remove(fontFace);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 return false; 187 return false;
188 } 188 }
189 189
190 CSSSegmentedFontFace* FontFaceCache::get(const FontDescription& fontDescription, const AtomicString& family) 190 CSSSegmentedFontFace* FontFaceCache::get(const FontDescription& fontDescription, const AtomicString& family)
191 { 191 {
192 TraitsMap* familyFontFaces = m_fontFaces.get(family); 192 TraitsMap* familyFontFaces = m_fontFaces.get(family);
193 if (!familyFontFaces || familyFontFaces->isEmpty()) 193 if (!familyFontFaces || familyFontFaces->isEmpty())
194 return 0; 194 return 0;
195 195
196 TraitsMap* segmentedFontFaceCache = m_fonts.get(family); 196 OwnPtr<TraitsMap>& segmentedFontFaceCache = m_fonts.add(family, nullptr).sto redValue->value;
197 if (!segmentedFontFaceCache) 197 if (!segmentedFontFaceCache)
198 segmentedFontFaceCache = m_fonts.set(family, adoptPtrWillBeNoop(new Trai tsMap)).storedValue->value.get(); 198 segmentedFontFaceCache = adoptPtr(new TraitsMap);
199 199
200 FontTraits traits = fontDescription.traits(); 200 FontTraits traits = fontDescription.traits();
201 CSSSegmentedFontFace* face = segmentedFontFaceCache->get(traits.mask()); 201 RefPtr<CSSSegmentedFontFace>& face = segmentedFontFaceCache->add(traits.mask (), nullptr).storedValue->value;
202 if (!face) { 202 if (!face) {
203 for (TraitsMap::const_iterator i = familyFontFaces->begin(); i != family FontFaces->end(); ++i) { 203 for (TraitsMap::const_iterator i = familyFontFaces->begin(); i != family FontFaces->end(); ++i) {
204 CSSSegmentedFontFace* candidate = i->value.get(); 204 CSSSegmentedFontFace* candidate = i->value.get();
205 FontTraits candidateTraits = candidate->traits(); 205 FontTraits candidateTraits = candidate->traits();
206 if (traits.style() == FontStyleNormal && candidateTraits.style() != FontStyleNormal) 206 if (traits.style() == FontStyleNormal && candidateTraits.style() != FontStyleNormal)
207 continue; 207 continue;
208 if (traits.variant() == FontVariantNormal && candidateTraits.variant () != FontVariantNormal) 208 if (traits.variant() == FontVariantNormal && candidateTraits.variant () != FontVariantNormal)
209 continue; 209 continue;
210 if (!face || compareFontFaces(candidate, face, traits)) 210 if (!face || compareFontFaces(candidate, face.get(), traits))
211 face = segmentedFontFaceCache->set(traits.mask(), candidate).sto redValue->value.get(); 211 face = candidate;
212 } 212 }
213 } 213 }
214 return face; 214 return face.get();
215 }
216
217 void FontFaceCache::trace(Visitor* visitor)
218 {
219 visitor->trace(m_fontFaces);
220 visitor->trace(m_fonts);
221 } 215 }
222 216
223 } 217 }
OLDNEW
« no previous file with comments | « Source/core/css/FontFaceCache.h ('k') | Source/core/css/resolver/FontBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698