Throttle timers that change the style of elements outside the viewport
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Nov 2014 19:23:43 +0000 (19:23 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Nov 2014 19:23:43 +0000 (19:23 +0000)
commit94128dd13e4db2fc90a3f9e9bcb129a2dba35145
treefa981f5bfe498e354f4947585ca026f35957397e
parenta3b3631cccddc8f1100041d86377f6c46ff8db4d
Throttle timers that change the style of elements outside the viewport
https://bugs.webkit.org/show_bug.cgi?id=138292

Reviewed by Antti Koivisto.

Throttle timers that change the style of elements outside the viewport
to 1 second, similarly to what was already done for timers interacting
with non user observable plugins. To be conservative, we don't throttle
timers that also cause DOM Tree modifications (e.g. adding/removing
nodes, modify element attributes).

On huffingtonpost.com, the CPU usage is at ~17% when the top scrolling
banner is inside the viewport on my machine. Without this patch, CPU
usage would stay ~17% when the banner is outside the viewport. Thanks
to timer throttling, CPU usage now goes down to ~1.5%, without user
observable side effects. The timers get unthrottled when they are
inside the viewport again (i.e. due to scrolling or layout).

On espn.com, the CPU usage goes down from ~7% at the top of the page
to ~1% when scrolling to the bottom of the page. On ebay.com, CPU
usage goes down from ~25% at the top of the page to less than 1% when
scrolling to the bottom of the page.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176212 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.h
Source/WebCore/css/CSSStyleDeclaration.h
Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
Source/WebCore/css/PropertySetCSSStyleDeclaration.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/page/DOMTimer.cpp
Source/WebCore/page/DOMTimer.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/Logging.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h