Chromium Code Reviews

Side by Side Diff: Source/core/css/CSSSegmentedFontFace.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/CSSFontFaceSource.cpp ('k') | Source/core/css/CSSValuePool.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) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 77 matching lines...)
88 } 88 }
89 89
90 void CSSSegmentedFontFace::addFontFace(PassRefPtr<FontFace> prpFontFace, bool cs sConnected) 90 void CSSSegmentedFontFace::addFontFace(PassRefPtr<FontFace> prpFontFace, bool cs sConnected)
91 { 91 {
92 RefPtr<FontFace> fontFace = prpFontFace; 92 RefPtr<FontFace> fontFace = prpFontFace;
93 pruneTable(); 93 pruneTable();
94 fontFace->cssFontFace()->setSegmentedFontFace(this); 94 fontFace->cssFontFace()->setSegmentedFontFace(this);
95 if (cssConnected) { 95 if (cssConnected) {
96 m_fontFaces.insertBefore(m_firstNonCssConnectedFace, fontFace); 96 m_fontFaces.insertBefore(m_firstNonCssConnectedFace, fontFace);
97 } else { 97 } else {
98 FontFaceList::AddResult result = m_fontFaces.add(fontFace); 98 // This is the only place in Blink that is using addReturnIterator.
99 FontFaceList::iterator iterator = m_fontFaces.addReturnIterator(fontFace );
99 if (m_firstNonCssConnectedFace == m_fontFaces.end()) 100 if (m_firstNonCssConnectedFace == m_fontFaces.end())
100 m_firstNonCssConnectedFace = result.iterator; 101 m_firstNonCssConnectedFace = iterator;
101 } 102 }
102 } 103 }
103 104
104 void CSSSegmentedFontFace::removeFontFace(PassRefPtr<FontFace> prpFontFace) 105 void CSSSegmentedFontFace::removeFontFace(PassRefPtr<FontFace> prpFontFace)
105 { 106 {
106 RefPtr<FontFace> fontFace = prpFontFace; 107 RefPtr<FontFace> fontFace = prpFontFace;
107 FontFaceList::iterator it = m_fontFaces.find(fontFace); 108 FontFaceList::iterator it = m_fontFaces.find(fontFace);
108 if (it == m_fontFaces.end()) 109 if (it == m_fontFaces.end())
109 return; 110 return;
110 111
(...skipping 20 matching lines...)
131 132
132 PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fo ntDescription) 133 PassRefPtr<FontData> CSSSegmentedFontFace::getFontData(const FontDescription& fo ntDescription)
133 { 134 {
134 if (!isValid()) 135 if (!isValid())
135 return 0; 136 return 0;
136 137
137 FontTraitsMask desiredTraitsMask = fontDescription.traitsMask(); 138 FontTraitsMask desiredTraitsMask = fontDescription.traitsMask();
138 AtomicString emptyFontFamily = ""; 139 AtomicString emptyFontFamily = "";
139 FontCacheKey key = fontDescription.cacheKey(emptyFontFamily, desiredTraitsMa sk); 140 FontCacheKey key = fontDescription.cacheKey(emptyFontFamily, desiredTraitsMa sk);
140 141
141 RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(key.hash(), 0).ite rator->value; 142 RefPtr<SegmentedFontData>& fontData = m_fontDataTable.add(key.hash(), 0).sto redValue->value;
142 if (fontData && fontData->numRanges()) 143 if (fontData && fontData->numRanges())
143 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has. 144 return fontData; // No release, we have a reference to an object in the cache which should retain the ref count it has.
144 145
145 if (!fontData) 146 if (!fontData)
146 fontData = SegmentedFontData::create(); 147 fontData = SegmentedFontData::create();
147 148
148 FontDescription requestedFontDescription(fontDescription); 149 FontDescription requestedFontDescription(fontDescription);
149 requestedFontDescription.setTraitsMask(m_traitsMask); 150 requestedFontDescription.setTraitsMask(m_traitsMask);
150 requestedFontDescription.setSyntheticBold(!(m_traitsMask & (FontWeight600Mas k | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTrait sMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight9 00Mask))); 151 requestedFontDescription.setSyntheticBold(!(m_traitsMask & (FontWeight600Mas k | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTrait sMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight9 00Mask)));
151 requestedFontDescription.setSyntheticItalic(!(m_traitsMask & FontStyleItalic Mask) && (desiredTraitsMask & FontStyleItalicMask)); 152 requestedFontDescription.setSyntheticItalic(!(m_traitsMask & FontStyleItalic Mask) && (desiredTraitsMask & FontStyleItalicMask));
(...skipping 62 matching lines...)
214 if (isLoading()) 215 if (isLoading())
215 m_callbacks.append(callback); 216 m_callbacks.append(callback);
216 else if (isLoaded()) 217 else if (isLoaded())
217 callback->notifyLoaded(this); 218 callback->notifyLoaded(this);
218 else 219 else
219 callback->notifyError(this); 220 callback->notifyError(this);
220 } 221 }
221 } 222 }
222 223
223 } 224 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSFontFaceSource.cpp ('k') | Source/core/css/CSSValuePool.cpp » ('j') | no next file with comments »

Powered by Google App Engine