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

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

Issue 2671933002: Migrate WTF::HashMap::add() to ::insert() (Closed)
Patch Set: rebase, add TODOs Created 3 years, 10 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 /* 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 29 matching lines...) Expand all
40 40
41 namespace blink { 41 namespace blink {
42 42
43 static unsigned s_version = 0; 43 static unsigned s_version = 0;
44 44
45 FontFaceCache::FontFaceCache() : m_version(0) {} 45 FontFaceCache::FontFaceCache() : m_version(0) {}
46 46
47 void FontFaceCache::add(CSSFontSelector* cssFontSelector, 47 void FontFaceCache::add(CSSFontSelector* cssFontSelector,
48 const StyleRuleFontFace* fontFaceRule, 48 const StyleRuleFontFace* fontFaceRule,
49 FontFace* fontFace) { 49 FontFace* fontFace) {
50 if (!m_styleRuleToFontFace.add(fontFaceRule, fontFace).isNewEntry) 50 if (!m_styleRuleToFontFace.insert(fontFaceRule, fontFace).isNewEntry)
51 return; 51 return;
52 addFontFace(cssFontSelector, fontFace, true); 52 addFontFace(cssFontSelector, fontFace, true);
53 } 53 }
54 54
55 void FontFaceCache::addFontFace(CSSFontSelector* cssFontSelector, 55 void FontFaceCache::addFontFace(CSSFontSelector* cssFontSelector,
56 FontFace* fontFace, 56 FontFace* fontFace,
57 bool cssConnected) { 57 bool cssConnected) {
58 FamilyToTraitsMap::AddResult traitsResult = 58 FamilyToTraitsMap::AddResult traitsResult =
59 m_fontFaces.add(fontFace->family(), nullptr); 59 m_fontFaces.insert(fontFace->family(), nullptr);
60 if (!traitsResult.storedValue->value) 60 if (!traitsResult.storedValue->value)
61 traitsResult.storedValue->value = new TraitsMap; 61 traitsResult.storedValue->value = new TraitsMap;
62 62
63 TraitsMap::AddResult segmentedFontFaceResult = 63 TraitsMap::AddResult segmentedFontFaceResult =
64 traitsResult.storedValue->value->add(fontFace->traits().bitfield(), 64 traitsResult.storedValue->value->insert(fontFace->traits().bitfield(),
65 nullptr); 65 nullptr);
66 if (!segmentedFontFaceResult.storedValue->value) 66 if (!segmentedFontFaceResult.storedValue->value)
67 segmentedFontFaceResult.storedValue->value = 67 segmentedFontFaceResult.storedValue->value =
68 CSSSegmentedFontFace::create(cssFontSelector, fontFace->traits()); 68 CSSSegmentedFontFace::create(cssFontSelector, fontFace->traits());
69 69
70 segmentedFontFaceResult.storedValue->value->addFontFace(fontFace, 70 segmentedFontFaceResult.storedValue->value->addFontFace(fontFace,
71 cssConnected); 71 cssConnected);
72 if (cssConnected) 72 if (cssConnected)
73 m_cssConnectedFontFaces.add(fontFace); 73 m_cssConnectedFontFaces.add(fontFace);
74 74
75 m_fonts.erase(fontFace->family()); 75 m_fonts.erase(fontFace->family());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void FontFaceCache::incrementVersion() { 130 void FontFaceCache::incrementVersion() {
131 m_version = ++s_version; 131 m_version = ++s_version;
132 } 132 }
133 133
134 CSSSegmentedFontFace* FontFaceCache::get(const FontDescription& fontDescription, 134 CSSSegmentedFontFace* FontFaceCache::get(const FontDescription& fontDescription,
135 const AtomicString& family) { 135 const AtomicString& family) {
136 TraitsMap* familyFontFaces = m_fontFaces.get(family); 136 TraitsMap* familyFontFaces = m_fontFaces.get(family);
137 if (!familyFontFaces || familyFontFaces->isEmpty()) 137 if (!familyFontFaces || familyFontFaces->isEmpty())
138 return nullptr; 138 return nullptr;
139 139
140 FamilyToTraitsMap::AddResult traitsResult = m_fonts.add(family, nullptr); 140 FamilyToTraitsMap::AddResult traitsResult = m_fonts.insert(family, nullptr);
141 if (!traitsResult.storedValue->value) 141 if (!traitsResult.storedValue->value)
142 traitsResult.storedValue->value = new TraitsMap; 142 traitsResult.storedValue->value = new TraitsMap;
143 143
144 FontTraits traits = fontDescription.traits(); 144 FontTraits traits = fontDescription.traits();
145 TraitsMap::AddResult faceResult = 145 TraitsMap::AddResult faceResult =
146 traitsResult.storedValue->value->add(traits.bitfield(), nullptr); 146 traitsResult.storedValue->value->insert(traits.bitfield(), nullptr);
147 if (!faceResult.storedValue->value) { 147 if (!faceResult.storedValue->value) {
148 for (const auto& item : *familyFontFaces) { 148 for (const auto& item : *familyFontFaces) {
149 CSSSegmentedFontFace* candidate = item.value.get(); 149 CSSSegmentedFontFace* candidate = item.value.get();
150 FontStyleMatcher styleMatcher(traits); 150 FontStyleMatcher styleMatcher(traits);
151 if (!faceResult.storedValue->value || 151 if (!faceResult.storedValue->value ||
152 styleMatcher.isCandidateBetter(candidate, 152 styleMatcher.isCandidateBetter(candidate,
153 faceResult.storedValue->value.get())) 153 faceResult.storedValue->value.get()))
154 faceResult.storedValue->value = candidate; 154 faceResult.storedValue->value = candidate;
155 } 155 }
156 } 156 }
157 return faceResult.storedValue->value.get(); 157 return faceResult.storedValue->value.get();
158 } 158 }
159 159
160 DEFINE_TRACE(FontFaceCache) { 160 DEFINE_TRACE(FontFaceCache) {
161 visitor->trace(m_fontFaces); 161 visitor->trace(m_fontFaces);
162 visitor->trace(m_fonts); 162 visitor->trace(m_fonts);
163 visitor->trace(m_styleRuleToFontFace); 163 visitor->trace(m_styleRuleToFontFace);
164 visitor->trace(m_cssConnectedFontFaces); 164 visitor->trace(m_cssConnectedFontFaces);
165 } 165 }
166 166
167 } // namespace blink 167 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSValuePool.h ('k') | third_party/WebKit/Source/core/css/RuleFeature.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698