Changeset 183778 in webkit
- Timestamp:
- May 4, 2015 4:42:56 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r183777 r183778 1 2015-05-04 Dean Jackson <dino@apple.com> 2 3 Create a named CSS property for system colors 4 https://bugs.webkit.org/show_bug.cgi?id=144423 5 6 Follow-up comments from Darin Adler. 7 8 * rendering/RenderThemeIOS.h: Cache a Color rather than an RGBA32. 9 * rendering/RenderThemeIOS.mm: 10 (WebCore::RenderThemeIOS::systemColor): Use "add" to avoid multiple hits on the HashMap, and 11 cache invalid responses so that we don't have to keep looking for non-existent colors. 12 * rendering/RenderThemeMac.h: Same as iOS. 13 * rendering/RenderThemeMac.mm: 14 (WebCore::RenderThemeMac::systemColor): 15 1 16 2015-05-04 Simon Fraser <simon.fraser@apple.com> 2 17 -
trunk/Source/WebCore/rendering/RenderThemeIOS.h
r183610 r183778 112 112 #endif 113 113 114 virtual Color systemColor(CSSValueID) const override;115 116 114 private: 117 115 RenderThemeIOS(); … … 121 119 FloatRect addRoundedBorderClip(const RenderObject& box, GraphicsContext*, const IntRect&); 122 120 121 virtual Color systemColor(CSSValueID) const override; 122 123 123 String m_mediaControlsScript; 124 124 String m_mediaControlsStyleSheet; 125 125 126 mutable HashMap<int, RGBA32> m_systemColorCache;126 mutable HashMap<int, Color> m_systemColorCache; 127 127 }; 128 128 -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r183610 r183778 1312 1312 #endif // ENABLE(VIDEO) 1313 1313 1314 Color RenderThemeIOS::systemColor(CSSValueID cssValueId) const 1315 { 1316 { 1317 auto it = m_systemColorCache.find(cssValueId); 1318 if (it != m_systemColorCache.end()) 1319 return it->value; 1320 } 1314 Color RenderThemeIOS::systemColor(CSSValueID cssValueID) const 1315 { 1316 auto addResult = m_systemColorCache.add(cssValueID, Color()); 1317 if (!addResult.isNewEntry) 1318 return addResult.iterator->value; 1321 1319 1322 1320 Color color; 1323 switch (cssValueI d) {1321 switch (cssValueID) { 1324 1322 case CSSValueAppleSystemBlue: 1325 1323 color = [getUIColorClass() systemBlueColor].CGColor; … … 1348 1346 1349 1347 if (!color.isValid()) 1350 color = RenderTheme::systemColor(cssValueId); 1351 1352 if (color.isValid()) 1353 m_systemColorCache.set(cssValueId, color.rgb()); 1354 1355 return color; 1348 color = RenderTheme::systemColor(cssValueID); 1349 1350 addResult.iterator->value = color; 1351 1352 return addResult.iterator->value; 1356 1353 } 1357 1354 -
trunk/Source/WebCore/rendering/RenderThemeMac.h
r180950 r183778 97 97 virtual IntRect progressBarRectForBounds(const RenderObject&, const IntRect&) const override; 98 98 99 virtual Color systemColor(CSSValueID) const override;100 99 // Controls color values returned from platformFocusRingColor(). systemColor() will be used when false. 101 100 bool usesTestModeFocusRingColor() const; … … 179 178 180 179 FloatRect convertToPaintingRect(const RenderObject& inputRenderer, const RenderObject& partRenderer, const FloatRect& inputRect, const IntRect&) const; 180 181 virtual Color systemColor(CSSValueID) const override; 181 182 182 183 // Get the control size based off the font. Used by some of the controls (like buttons). … … 248 249 bool m_isSliderThumbVerticalPressed; 249 250 250 mutable HashMap<int, RGBA32> m_systemColorCache;251 mutable HashMap<int, Color> m_systemColorCache; 251 252 252 253 RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; -
trunk/Source/WebCore/rendering/RenderThemeMac.mm
r183610 r183778 456 456 } 457 457 458 Color RenderThemeMac::systemColor(CSSValueID cssValueId) const 459 { 460 { 461 auto it = m_systemColorCache.find(cssValueId); 462 if (it != m_systemColorCache.end()) 463 return it->value; 464 } 458 Color RenderThemeMac::systemColor(CSSValueID cssValueID) const 459 { 460 auto addResult = m_systemColorCache.add(cssValueID, Color()); 461 if (!addResult.isNewEntry) 462 return addResult.iterator->value; 465 463 466 464 Color color; 467 switch (cssValueI d) {465 switch (cssValueID) { 468 466 case CSSValueActiveborder: 469 467 color = convertNSColorToColor([NSColor keyboardFocusIndicatorColor]); … … 603 601 604 602 if (!color.isValid()) 605 color = RenderTheme::systemColor(cssValueId); 606 607 if (color.isValid()) 608 m_systemColorCache.set(cssValueId, color.rgb()); 609 610 return color; 603 color = RenderTheme::systemColor(cssValueID); 604 605 addResult.iterator->value = color; 606 607 return addResult.iterator->value; 611 608 } 612 609
Note: See TracChangeset
for help on using the changeset viewer.