WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP Patch
timer_throttling_non_visible_elements.patch (text/plain), 6.74 KB, created by
Chris Dumez
on 2014-11-02 09:37:48 PST
(
hide
)
Description:
WIP Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2014-11-02 09:37:48 PST
Size:
6.74 KB
patch
obsolete
>diff --git a/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp >index 11de5d3..278b48b 100644 >--- a/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp >+++ b/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp >@@ -33,6 +33,7 @@ > #include "HashTools.h" > #include "JSCSSValue.h" > #include "JSNode.h" >+#include "PropertySetCSSStyleDeclaration.h" > #include "RuntimeEnabledFeatures.h" > #include "Settings.h" > #include "StyleProperties.h" >@@ -338,6 +339,10 @@ bool JSCSSStyleDeclaration::putDelegate(ExecState* exec, PropertyName propertyNa > } > } > >+ // Check if we should throttle the timer if it is changing the style of a non user-observable Element. >+ if (auto* element = static_cast<PropertySetCSSStyleDeclaration&>(impl()).parentElement()) >+ DOMTimer::scriptDidInteractWithElement(*element); >+ > ExceptionCode ec = 0; > impl().setPropertyInternal(static_cast<CSSPropertyID>(propertyInfo.propertyID), propValue, important, ec); > setDOMException(exec, ec); >diff --git a/Source/WebCore/dom/Element.cpp b/Source/WebCore/dom/Element.cpp >index 5381bc8..27485c1 100644 >--- a/Source/WebCore/dom/Element.cpp >+++ b/Source/WebCore/dom/Element.cpp >@@ -2329,6 +2329,18 @@ bool Element::shouldAppearIndeterminate() const > return false; > } > >+bool Element::isUserObservable() >+{ >+ if (!renderer()) >+ return false; >+ >+ auto& frameView = renderer()->view().frameView(); >+ if (frameView.isOffscreen()) >+ return false; >+ auto visibleRect = frameView.windowToContents(frameView.windowClipRect()); >+ return visibleRect.intersects(enclosingIntRect(renderer()->absoluteClippedOverflowRect())); >+} >+ > DOMTokenList& Element::classList() > { > ElementRareData& data = ensureElementRareData(); >diff --git a/Source/WebCore/dom/Element.h b/Source/WebCore/dom/Element.h >index c82ce97..e8b24d0 100644 >--- a/Source/WebCore/dom/Element.h >+++ b/Source/WebCore/dom/Element.h >@@ -200,6 +200,8 @@ public: > double offsetWidth(); > double offsetHeight(); > >+ bool isUserObservable(); >+ > // FIXME: Replace uses of offsetParent in the platform with calls > // to the render layer and merge bindingsOffsetParent and offsetParent. > Element* bindingsOffsetParent(); >diff --git a/Source/WebCore/page/DOMTimer.cpp b/Source/WebCore/page/DOMTimer.cpp >index d8c8118..3549a33 100644 >--- a/Source/WebCore/page/DOMTimer.cpp >+++ b/Source/WebCore/page/DOMTimer.cpp >@@ -48,14 +48,14 @@ > namespace WebCore { > > static const int maxIntervalForUserGestureForwarding = 1000; // One second matches Gecko. >-static const int minIntervalForNonUserObservablePluginScriptTimers = 1000; // Empirically determined to maximize battery life. >+static const int minIntervalForNonUserObservableElementScriptTimers = 1000; // Empirically determined to maximize battery life. > static const int maxTimerNestingLevel = 5; > static const double oneMillisecond = 0.001; > > struct DOMTimerFireState { > DOMTimerFireState(ScriptExecutionContext* context) >- : scriptDidInteractWithNonUserObservablePlugin(false) >- , scriptDidInteractWithUserObservablePlugin(false) >+ : scriptDidInteractWithNonUserObservableElement(false) >+ , scriptDidInteractWithUserObservableElement(false) > , shouldSetCurrent(context->isDocument()) > { > // For worker threads, don't update the current DOMTimerFireState. >@@ -74,8 +74,8 @@ struct DOMTimerFireState { > > static DOMTimerFireState* current; > >- bool scriptDidInteractWithNonUserObservablePlugin; >- bool scriptDidInteractWithUserObservablePlugin; >+ bool scriptDidInteractWithNonUserObservableElement; >+ bool scriptDidInteractWithUserObservableElement; > > private: > bool shouldSetCurrent; >@@ -190,10 +190,10 @@ void DOMTimer::removeById(ScriptExecutionContext* context, int timeoutId) > > void DOMTimer::updateThrottlingStateIfNecessary(const DOMTimerFireState& fireState) > { >- if (fireState.scriptDidInteractWithUserObservablePlugin && m_throttleState != ShouldNotThrottle) { >+ if (fireState.scriptDidInteractWithUserObservableElement && m_throttleState != ShouldNotThrottle) { > m_throttleState = ShouldNotThrottle; > updateTimerIntervalIfNecessary(); >- } else if (fireState.scriptDidInteractWithNonUserObservablePlugin && m_throttleState == Undetermined) { >+ } else if (fireState.scriptDidInteractWithNonUserObservableElement && m_throttleState == Undetermined) { > m_throttleState = ShouldThrottle; > updateTimerIntervalIfNecessary(); > } >@@ -205,9 +205,20 @@ void DOMTimer::scriptDidInteractWithPlugin(HTMLPlugInElement& pluginElement) > return; > > if (pluginElement.isUserObservable()) >- DOMTimerFireState::current->scriptDidInteractWithUserObservablePlugin = true; >+ DOMTimerFireState::current->scriptDidInteractWithUserObservableElement = true; > else >- DOMTimerFireState::current->scriptDidInteractWithNonUserObservablePlugin = true; >+ DOMTimerFireState::current->scriptDidInteractWithNonUserObservableElement = true; >+} >+ >+void DOMTimer::scriptDidInteractWithElement(StyledElement& element) >+{ >+ if (!DOMTimerFireState::current) >+ return; >+ >+ if (element.isUserObservable()) >+ DOMTimerFireState::current->scriptDidInteractWithUserObservableElement = true; >+ else >+ DOMTimerFireState::current->scriptDidInteractWithNonUserObservableElement = true; > } > > void DOMTimer::fired() >@@ -337,7 +348,7 @@ double DOMTimer::intervalClampedToMinimum() const > // Apply two throttles - the global (per Page) minimum, and also a per-timer throttle. > intervalInSeconds = std::max(intervalInSeconds, scriptExecutionContext()->minimumTimerInterval()); > if (m_throttleState == ShouldThrottle) >- intervalInSeconds = std::max(intervalInSeconds, minIntervalForNonUserObservablePluginScriptTimers * oneMillisecond); >+ intervalInSeconds = std::max(intervalInSeconds, minIntervalForNonUserObservableElementScriptTimers * oneMillisecond); > return intervalInSeconds; > } > >diff --git a/Source/WebCore/page/DOMTimer.h b/Source/WebCore/page/DOMTimer.h >index dd1b1f4..65ba27c 100644 >--- a/Source/WebCore/page/DOMTimer.h >+++ b/Source/WebCore/page/DOMTimer.h >@@ -36,6 +36,7 @@ namespace WebCore { > struct DOMTimerFireState; > class HTMLPlugInElement; > class ScheduledAction; >+ class StyledElement; > > class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimer { > WTF_MAKE_NONCOPYABLE(DOMTimer); >@@ -51,6 +52,7 @@ namespace WebCore { > void updateTimerIntervalIfNecessary(); > > static void scriptDidInteractWithPlugin(HTMLPlugInElement&); >+ static void scriptDidInteractWithElement(StyledElement&); > > private: > DOMTimer(ScriptExecutionContext*, std::unique_ptr<ScheduledAction>, int interval, bool singleShot);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 138292
:
240813
|
240814
|
240818
|
240820
|
240857
|
240861
|
240886
|
241044
|
241050
|
241073
|
241075
|
241449
|
241467
|
241471
|
241557
|
241563
|
241618
|
241721