Skip to content
  • cmuppala@apple.com's avatar
    Add runtime setting for hidden page DOM timer throttling and CSS animation suspension · a756fa61
    cmuppala@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=112308
    
    Reviewed by Gavin Barraclough.
    
    Source/WebCore:
    
    No new tests.  Only adding settings to enable/disable existing features
    and hence existing tests suffice.
    
    * WebCore.exp.in:
    * page/Page.cpp:
    (WebCore::Page::setVisibilityState): Check if DOM timer throttling
    and CSS animation suspension are enabled before turning them on.
    (WebCore::Page::hiddenPageDOMTimerThrottlingStateChanged): Start or stop
    DOM timer throttling based on page visibility and the new setting state.
    (WebCore::Page::hiddenPageCSSAnimationSuspensionStateChanged): Ditto
    for CSS animation suspension.
    * page/Page.h:
    * page/Settings.cpp:
    (WebCore::Settings::Settings): Initialize the flags for enabling hidden
    page DOM timer throttling and CSS animation suspension to false.
    (WebCore::Settings::setHiddenPageDOMTimerThrottlingEnabled): Update flag
    and notify page that the state of the setting has changed.
    (WebCore::Settings::setHiddenPageCSSAnimationSuspensionEnabled): Ditto.
    * page/Settings.h:
    (WebCore::Settings::hiddenPageDOMTimerThrottlingEnabled):
    (WebCore::Settings::hiddenPageCSSAnimationSuspensionEnabled):
    
    Source/WebKit/mac:
    
    Add private preference for enabling/disabling hidden page DOM timer
    throttling and CSS animation suspension.  The preference should be
    disabled by default to avoid compatibility issues.
    
    * WebView/WebPreferenceKeysPrivate.h:
    * WebView/WebPreferences.mm:
    (+[WebPreferences initialize]):
    (-[WebPreferences hiddenPageDOMTimerThrottlingEnabled]):
    (-[WebPreferences setHiddenPageDOMTimerThrottlingEnabled:]):
    (-[WebPreferences hiddenPageCSSAnimationSuspensionEnabled]):
    (-[WebPreferences setHiddenPageCSSAnimationSuspensionEnabled:]):
    * WebView/WebPreferencesPrivate.h:
    * WebView/WebView.mm:
    (-[WebView _preferencesChanged:]):
    
    Source/WebKit2:
    
    Add private preference for enabling/disabling hidden page DOM timer
    throttling and CSS animation suspension.  The preference should be
    enabled by default only on Mac, where WebKit2 is a private API and
    hence compatibility is less of a issue.
    
    * Shared/WebPreferencesStore.h:
    * UIProcess/API/C/WKPreferences.cpp:
    (WKPreferencesSetHiddenPageDOMTimerThrottlingEnabled):
    (WKPreferencesGetHiddenPageDOMTimerThrottlingEnabled):
    (WKPreferencesSetHiddenPageCSSAnimationSuspensionEnabled):
    (WKPreferencesGetHiddenPageCSSAnimationSuspensionEnabled):
    * UIProcess/API/C/WKPreferencesPrivate.h:
    * WebProcess/InjectedBundle/InjectedBundle.cpp:
    (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): Allow
    WebKitTestRunner to override hiddenPageDOMTimerThrottlingEnabled.
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::updatePreferences):
    
    LayoutTests:
    
    Hidden page DOM timer throttling is disabled by default in WebKit1 and
    in WebKit2 for platforms other than Mac.  Override the preference to
    enable it during the test.
    
    * fast/dom/timer-throttling-hidden-page.html:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146704 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    a756fa61