Changeset 263282 in webkit
- Timestamp:
- Jun 19, 2020, 1:13:14 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
rendering/RenderThemeIOS.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r263281 r263282 1 2020-06-19 Chris Dumez <cdumez@apple.com> 2 3 [iOS] RenderThemeIOS::cssValueToSystemColorMap() does an unnecessary linear search under systemColorFromCSSValueID() 4 https://bugs.webkit.org/show_bug.cgi?id=213396 5 6 Reviewed by Timothy Hatcher. 7 8 RenderThemeIOS::cssValueToSystemColorMap() does an unnecessary linear search under systemColorFromCSSValueID(). 9 cssValueToSystemColorMap() already has the selector, yet it passes a CSSValueID to systemColorFromCSSValueID() which 10 then does a linear search to match the CSSValueID to a selector. This was very inefficient / unfortunate. 11 12 This patch introduces a systemColorFromCSSValueIDSelector() which takes in a selector instead of a CSSValueID. I have 13 also moved the constructor of the LocalCurrentTraitCollection variable to the call site so that we don't keep 14 constructing / destroying it for each loop iteration. The traces show us spending a lot of time in its constructor / 15 destructor. 16 17 * rendering/RenderThemeIOS.mm: 18 (WebCore::systemColorFromCSSValueIDSelector): 19 (WebCore::RenderThemeIOS::cssValueToSystemColorMap): 20 1 21 2020-06-19 James Darpinian <jdarpinian@chromium.org> 2 22 -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r263278 r263282 1284 1284 } 1285 1285 1286 static inline Optional<Color> systemColorFromCSSValueIDSelector(CSSValueIDAndSelector idAndSelector) 1287 { 1288 if (auto color = wtfObjCMsgSend<UIColor *>(PAL::getUIColorClass(), idAndSelector.selector)) 1289 return Color { color.CGColor, Color::Semantic }; 1290 return WTF::nullopt; 1291 } 1292 1286 1293 static Optional<Color> systemColorFromCSSValueID(CSSValueID cssValueID, bool useDarkAppearance, bool useElevatedUserInterfaceLevel) 1287 1294 { … … 1315 1322 static const NeverDestroyed<CSSValueToSystemColorMap> colorMap = [] { 1316 1323 CSSValueToSystemColorMap map; 1317 for (auto& cssValueIDSelector : cssValueIDSelectorList()) { 1318 for (bool useDarkAppearance : { false, true }) { 1319 for (bool useElevatedUserInterfaceLevel : { false, true }) { 1320 if (auto color = systemColorFromCSSValueID(cssValueIDSelector.cssValueID, useDarkAppearance, useElevatedUserInterfaceLevel)) 1321 map.add(CSSValueKey { cssValueIDSelector.cssValueID, useDarkAppearance, useElevatedUserInterfaceLevel }, *color); 1324 for (bool useDarkAppearance : { false, true }) { 1325 for (bool useElevatedUserInterfaceLevel : { false, true }) { 1326 LocalCurrentTraitCollection localTraitCollection(useDarkAppearance, useElevatedUserInterfaceLevel); 1327 for (auto& cssValueIDSelector : cssValueIDSelectorList()) { 1328 if (auto color = systemColorFromCSSValueIDSelector(cssValueIDSelector)) 1329 map.add(CSSValueKey { cssValueIDSelector.cssValueID, useDarkAppearance, useElevatedUserInterfaceLevel }, WTFMove(*color)); 1322 1330 } 1323 1331 }
Note:
See TracChangeset
for help on using the changeset viewer.