Chromium Code Reviews

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

Issue 138643003: Simpler return value of HashTable::add/HashMap:add and others (Closed)
Patch Set: Daily master update (now with base url?) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « Source/core/css/CSSValuePool.cpp ('k') | Source/core/css/PropertySetCSSStyleDeclaration.cpp » ('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...)
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 OwnPtr<TraitsMap>& familyFontFaces = m_fontFaces.add(fontFace->family(), nul lptr).iterator->value; 61 OwnPtr<TraitsMap>& familyFontFaces = m_fontFaces.add(fontFace->family(), nul lptr).storedValue->value;
62 if (!familyFontFaces) 62 if (!familyFontFaces)
63 familyFontFaces = adoptPtr(new TraitsMap); 63 familyFontFaces = adoptPtr(new TraitsMap);
64 64
65 RefPtr<CSSSegmentedFontFace>& segmentedFontFace = familyFontFaces->add(fontF ace->traitsMask(), 0).iterator->value; 65 RefPtr<CSSSegmentedFontFace>& segmentedFontFace = familyFontFaces->add(fontF ace->traitsMask(), 0).storedValue->value;
66 if (!segmentedFontFace) 66 if (!segmentedFontFace)
67 segmentedFontFace = CSSSegmentedFontFace::create(cssFontSelector, static _cast<FontTraitsMask>(fontFace->traitsMask())); 67 segmentedFontFace = CSSSegmentedFontFace::create(cssFontSelector, static _cast<FontTraitsMask>(fontFace->traitsMask()));
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
(...skipping 110 matching lines...)
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 OwnPtr<TraitsMap>& segmentedFontFaceCache = m_fonts.add(family, nullptr).ite rator->value; 196 OwnPtr<TraitsMap>& segmentedFontFaceCache = m_fonts.add(family, nullptr).sto redValue->value;
197 if (!segmentedFontFaceCache) 197 if (!segmentedFontFaceCache)
198 segmentedFontFaceCache = adoptPtr(new TraitsMap); 198 segmentedFontFaceCache = adoptPtr(new TraitsMap);
199 199
200 FontTraitsMask traitsMask = fontDescription.traitsMask(); 200 FontTraitsMask traitsMask = fontDescription.traitsMask();
201 201
202 RefPtr<CSSSegmentedFontFace>& face = segmentedFontFaceCache->add(traitsMask, 0).iterator->value; 202 RefPtr<CSSSegmentedFontFace>& face = segmentedFontFaceCache->add(traitsMask, 0).storedValue->value;
203 if (!face) { 203 if (!face) {
204 for (TraitsMap::const_iterator i = familyFontFaces->begin(); i != family FontFaces->end(); ++i) { 204 for (TraitsMap::const_iterator i = familyFontFaces->begin(); i != family FontFaces->end(); ++i) {
205 CSSSegmentedFontFace* candidate = i->value.get(); 205 CSSSegmentedFontFace* candidate = i->value.get();
206 unsigned candidateTraitsMask = candidate->traitsMask(); 206 unsigned candidateTraitsMask = candidate->traitsMask();
207 if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & Fo ntStyleNormalMask)) 207 if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & Fo ntStyleNormalMask))
208 continue; 208 continue;
209 if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask)) 209 if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask))
210 continue; 210 continue;
211 if (!face || compareFontFaces(candidate, face.get(), traitsMask)) 211 if (!face || compareFontFaces(candidate, face.get(), traitsMask))
212 face = candidate; 212 face = candidate;
213 } 213 }
214 } 214 }
215 return face.get(); 215 return face.get();
216 } 216 }
217 217
218 } 218 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSValuePool.cpp ('k') | Source/core/css/PropertySetCSSStyleDeclaration.cpp » ('j') | no next file with comments »

Powered by Google App Engine