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

Side by Side Diff: Source/core/css/CSSValuePool.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. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/CSSSegmentedFontFace.cpp ('k') | Source/core/css/FontFaceCache.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) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return m_colorBlack; 86 return m_colorBlack;
87 87
88 // Just wipe out the cache and start rebuilding if it gets too big. 88 // Just wipe out the cache and start rebuilding if it gets too big.
89 const unsigned maximumColorCacheSize = 512; 89 const unsigned maximumColorCacheSize = 512;
90 if (m_colorValueCache.size() > maximumColorCacheSize) 90 if (m_colorValueCache.size() > maximumColorCacheSize)
91 m_colorValueCache.clear(); 91 m_colorValueCache.clear();
92 92
93 RefPtrWillBeRawPtr<CSSPrimitiveValue> dummyValue; 93 RefPtrWillBeRawPtr<CSSPrimitiveValue> dummyValue;
94 ColorValueCache::AddResult entry = m_colorValueCache.add(rgbValue, dummyValu e); 94 ColorValueCache::AddResult entry = m_colorValueCache.add(rgbValue, dummyValu e);
95 if (entry.isNewEntry) 95 if (entry.isNewEntry)
96 entry.iterator->value = CSSPrimitiveValue::createColor(rgbValue); 96 entry.storedValue->value = CSSPrimitiveValue::createColor(rgbValue);
97 return entry.iterator->value; 97 return entry.storedValue->value;
98 } 98 }
99 99
100 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSValuePool::createValue(double value , CSSPrimitiveValue::UnitTypes type) 100 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSValuePool::createValue(double value , CSSPrimitiveValue::UnitTypes type)
101 { 101 {
102 if (value < 0 || value > maximumCacheableIntegerValue) 102 if (value < 0 || value > maximumCacheableIntegerValue)
103 return CSSPrimitiveValue::create(value, type); 103 return CSSPrimitiveValue::create(value, type);
104 104
105 int intValue = static_cast<int>(value); 105 int intValue = static_cast<int>(value);
106 if (value != intValue) 106 if (value != intValue)
107 return CSSPrimitiveValue::create(value, type); 107 return CSSPrimitiveValue::create(value, type);
(...skipping 16 matching lines...) Expand all
124 } 124 }
125 } 125 }
126 126
127 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSValuePool::createValue(const Length & value, const RenderStyle& style) 127 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSValuePool::createValue(const Length & value, const RenderStyle& style)
128 { 128 {
129 return CSSPrimitiveValue::create(value, style.effectiveZoom()); 129 return CSSPrimitiveValue::create(value, style.effectiveZoom());
130 } 130 }
131 131
132 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(co nst String& familyName) 132 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(co nst String& familyName)
133 { 133 {
134 RefPtrWillBeMember<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add(fa milyName, 0).iterator->value; 134 RefPtrWillBeMember<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add(fa milyName, 0).storedValue->value;
135 if (!value) 135 if (!value)
136 value = CSSPrimitiveValue::create(familyName, CSSPrimitiveValue::CSS_STR ING); 136 value = CSSPrimitiveValue::create(familyName, CSSPrimitiveValue::CSS_STR ING);
137 return value; 137 return value;
138 } 138 }
139 139
140 PassRefPtrWillBeRawPtr<CSSValueList> CSSValuePool::createFontFaceValue(const Ato micString& string) 140 PassRefPtrWillBeRawPtr<CSSValueList> CSSValuePool::createFontFaceValue(const Ato micString& string)
141 { 141 {
142 // Just wipe out the cache and start rebuilding if it gets too big. 142 // Just wipe out the cache and start rebuilding if it gets too big.
143 const unsigned maximumFontFaceCacheSize = 128; 143 const unsigned maximumFontFaceCacheSize = 128;
144 if (m_fontFaceValueCache.size() > maximumFontFaceCacheSize) 144 if (m_fontFaceValueCache.size() > maximumFontFaceCacheSize)
145 m_fontFaceValueCache.clear(); 145 m_fontFaceValueCache.clear();
146 146
147 RefPtrWillBeMember<CSSValueList>& value = m_fontFaceValueCache.add(string, 0 ).iterator->value; 147 RefPtrWillBeMember<CSSValueList>& value = m_fontFaceValueCache.add(string, 0 ).storedValue->value;
148 if (!value) 148 if (!value)
149 value = BisonCSSParser::parseFontFaceValue(string); 149 value = BisonCSSParser::parseFontFaceValue(string);
150 return value; 150 return value;
151 } 151 }
152 152
153 void CSSValuePool::trace(Visitor* visitor) 153 void CSSValuePool::trace(Visitor* visitor)
154 { 154 {
155 visitor->trace(m_inheritedValue); 155 visitor->trace(m_inheritedValue);
156 visitor->trace(m_implicitInitialValue); 156 visitor->trace(m_implicitInitialValue);
157 visitor->trace(m_explicitInitialValue); 157 visitor->trace(m_explicitInitialValue);
158 visitor->trace(m_identifierValueCache); 158 visitor->trace(m_identifierValueCache);
159 visitor->trace(m_colorValueCache); 159 visitor->trace(m_colorValueCache);
160 visitor->trace(m_colorTransparent); 160 visitor->trace(m_colorTransparent);
161 visitor->trace(m_colorWhite); 161 visitor->trace(m_colorWhite);
162 visitor->trace(m_colorBlack); 162 visitor->trace(m_colorBlack);
163 visitor->trace(m_pixelValueCache); 163 visitor->trace(m_pixelValueCache);
164 visitor->trace(m_percentValueCache); 164 visitor->trace(m_percentValueCache);
165 visitor->trace(m_numberValueCache); 165 visitor->trace(m_numberValueCache);
166 visitor->trace(m_fontFaceValueCache); 166 visitor->trace(m_fontFaceValueCache);
167 visitor->trace(m_fontFamilyValueCache); 167 visitor->trace(m_fontFamilyValueCache);
168 } 168 }
169 169
170 } 170 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSSegmentedFontFace.cpp ('k') | Source/core/css/FontFaceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698