Changeset 152214 in webkit


Ignore:
Timestamp:
Jun 29, 2013 1:27:08 PM (11 years ago)
Author:
Simon Fraser
Message:

Avoid calling into Objective-C every time we get the scrollbar width
https://bugs.webkit.org/show_bug.cgi?id=118216

Reviewed by Geoffrey Garen.

Profiling shows that calling Scrollbar::isOverlayScrollbar() is somewhat
expensive, because it calls down into Objective-C. Fix by caching in
ScrollbarThemeMac whether we're using overlay scrollbars. We update this
cache on creation, and when preferences change; ScrollAnimatorMac::updateScrollerStyle()
is the function that gets called when the user changes the setting in System Preferences.

  • platform/ScrollbarTheme.h:

(WebCore::ScrollbarTheme::usesOverlayScrollbarsChanged):

  • platform/mac/ScrollAnimatorMac.mm:

(WebCore::ScrollAnimatorMac::updateScrollerStyle):

  • platform/mac/ScrollbarThemeMac.h:
  • platform/mac/ScrollbarThemeMac.mm:

(WebCore::ScrollbarThemeMac::preferencesChanged):
(WebCore::ScrollbarThemeMac::usesOverlayScrollbars):
(WebCore::ScrollbarThemeMac::usesOverlayScrollbarsChanged):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152213 r152214  
     12013-06-29  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Avoid calling into Objective-C every time we get the scrollbar width
     4        https://bugs.webkit.org/show_bug.cgi?id=118216
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Profiling shows that calling Scrollbar::isOverlayScrollbar() is somewhat
     9        expensive, because it calls down into Objective-C. Fix by caching in
     10        ScrollbarThemeMac whether we're using overlay scrollbars. We update this
     11        cache on creation, and when preferences change; ScrollAnimatorMac::updateScrollerStyle()
     12        is the function that gets called when the user changes the setting in System Preferences.
     13
     14        * platform/ScrollbarTheme.h:
     15        (WebCore::ScrollbarTheme::usesOverlayScrollbarsChanged):
     16        * platform/mac/ScrollAnimatorMac.mm:
     17        (WebCore::ScrollAnimatorMac::updateScrollerStyle):
     18        * platform/mac/ScrollbarThemeMac.h:
     19        * platform/mac/ScrollbarThemeMac.mm:
     20        (WebCore::ScrollbarThemeMac::preferencesChanged):
     21        (WebCore::ScrollbarThemeMac::usesOverlayScrollbars):
     22        (WebCore::ScrollbarThemeMac::usesOverlayScrollbarsChanged):
     23
    1242013-06-29  Simon Fraser  <simon.fraser@apple.com>
    225
  • trunk/Source/WebCore/platform/ScrollbarTheme.h

    r144397 r152214  
    5858    virtual bool supportsControlTints() const { return false; }
    5959    virtual bool usesOverlayScrollbars() const { return false; }
     60    virtual void usesOverlayScrollbarsChanged() { }
    6061    virtual void updateScrollbarOverlayStyle(ScrollbarThemeClient*) { }
    6162
  • trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm

    r150399 r152214  
    12131213        return;
    12141214    }
     1215   
     1216    macTheme->usesOverlayScrollbarsChanged();
    12151217
    12161218    NSScrollerStyle newStyle = [m_scrollbarPainterController.get() scrollerStyle];
  • trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h

    r147860 r152214  
    4848    virtual bool supportsControlTints() const { return true; }
    4949    virtual bool usesOverlayScrollbars() const;
     50    virtual void usesOverlayScrollbarsChanged() OVERRIDE;
    5051    virtual void updateScrollbarOverlayStyle(ScrollbarThemeClient*);
    5152
  • trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm

    r149980 r152214  
    134134static float gAutoscrollButtonDelay = 0.05f;
    135135static bool gJumpOnTrackClick = false;
     136static bool gUsesOverlayScrollbars = false;
    136137
    137138static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsDoubleEnd;
     
    227228    gAutoscrollButtonDelay = [defaults floatForKey:@"NSScrollerButtonPeriod"];
    228229    gJumpOnTrackClick = [defaults boolForKey:@"AppleScrollerPagingBehavior"];
     230    usesOverlayScrollbarsChanged();
    229231}
    230232
     
    242244bool ScrollbarThemeMac::usesOverlayScrollbars() const
    243245{
     246    return gUsesOverlayScrollbars;
     247}
     248
     249void ScrollbarThemeMac::usesOverlayScrollbarsChanged()
     250{
    244251    if (isScrollbarOverlayAPIAvailable())
    245         return recommendedScrollerStyle() == NSScrollerStyleOverlay;
     252        gUsesOverlayScrollbars = recommendedScrollerStyle() == NSScrollerStyleOverlay;
    246253    else
    247         return false;
     254        gUsesOverlayScrollbars = false;
    248255}
    249256
Note: See TracChangeset for help on using the changeset viewer.