Changeset 183778 in webkit


Ignore:
Timestamp:
May 4, 2015 4:42:56 PM (9 years ago)
Author:
dino@apple.com
Message:

Create a named CSS property for system colors
https://bugs.webkit.org/show_bug.cgi?id=144423

Follow-up comments from Darin Adler.

  • rendering/RenderThemeIOS.h: Cache a Color rather than an RGBA32.
  • rendering/RenderThemeIOS.mm:

(WebCore::RenderThemeIOS::systemColor): Use "add" to avoid multiple hits on the HashMap, and
cache invalid responses so that we don't have to keep looking for non-existent colors.

  • rendering/RenderThemeMac.h: Same as iOS.
  • rendering/RenderThemeMac.mm:

(WebCore::RenderThemeMac::systemColor):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r183777 r183778  
     12015-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
    1162015-05-04  Simon Fraser  <simon.fraser@apple.com>
    217
  • trunk/Source/WebCore/rendering/RenderThemeIOS.h

    r183610 r183778  
    112112#endif
    113113
    114     virtual Color systemColor(CSSValueID) const override;
    115 
    116114private:
    117115    RenderThemeIOS();
     
    121119    FloatRect addRoundedBorderClip(const RenderObject& box, GraphicsContext*, const IntRect&);
    122120
     121    virtual Color systemColor(CSSValueID) const override;
     122
    123123    String m_mediaControlsScript;
    124124    String m_mediaControlsStyleSheet;
    125125
    126     mutable HashMap<int, RGBA32> m_systemColorCache;
     126    mutable HashMap<int, Color> m_systemColorCache;
    127127};
    128128
  • trunk/Source/WebCore/rendering/RenderThemeIOS.mm

    r183610 r183778  
    13121312#endif // ENABLE(VIDEO)
    13131313
    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     }
     1314Color RenderThemeIOS::systemColor(CSSValueID cssValueID) const
     1315{
     1316    auto addResult = m_systemColorCache.add(cssValueID, Color());
     1317    if (!addResult.isNewEntry)
     1318        return addResult.iterator->value;
    13211319
    13221320    Color color;
    1323     switch (cssValueId) {
     1321    switch (cssValueID) {
    13241322    case CSSValueAppleSystemBlue:
    13251323        color = [getUIColorClass() systemBlueColor].CGColor;
     
    13481346
    13491347    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;
    13561353}
    13571354
  • trunk/Source/WebCore/rendering/RenderThemeMac.h

    r180950 r183778  
    9797    virtual IntRect progressBarRectForBounds(const RenderObject&, const IntRect&) const override;
    9898
    99     virtual Color systemColor(CSSValueID) const override;
    10099    // Controls color values returned from platformFocusRingColor(). systemColor() will be used when false.
    101100    bool usesTestModeFocusRingColor() const;
     
    179178
    180179    FloatRect convertToPaintingRect(const RenderObject& inputRenderer, const RenderObject& partRenderer, const FloatRect& inputRect, const IntRect&) const;
     180
     181    virtual Color systemColor(CSSValueID) const override;
    181182
    182183    // Get the control size based off the font. Used by some of the controls (like buttons).
     
    248249    bool m_isSliderThumbVerticalPressed;
    249250
    250     mutable HashMap<int, RGBA32> m_systemColorCache;
     251    mutable HashMap<int, Color> m_systemColorCache;
    251252
    252253    RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver;
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r183610 r183778  
    456456}
    457457
    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     }
     458Color RenderThemeMac::systemColor(CSSValueID cssValueID) const
     459{
     460    auto addResult = m_systemColorCache.add(cssValueID, Color());
     461    if (!addResult.isNewEntry)
     462        return addResult.iterator->value;
    465463
    466464    Color color;
    467     switch (cssValueId) {
     465    switch (cssValueID) {
    468466    case CSSValueActiveborder:
    469467        color = convertNSColorToColor([NSColor keyboardFocusIndicatorColor]);
     
    603601
    604602    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;
    611608}
    612609
Note: See TracChangeset for help on using the changeset viewer.