Port DOMTimer from std::chrono::milliseconds to WTF::Seconds type
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Mar 2017 17:11:06 +0000 (17:11 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Mar 2017 17:11:06 +0000 (17:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169236

Reviewed by Simon Fraser.

Source/WebCore:

* dom/Document.cpp:
(WebCore::Document::minimumDOMTimerInterval):
(WebCore::Document::timerAlignmentInterval):
* dom/Document.h:
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::adjustMinimumDOMTimerInterval):
(WebCore::ScriptExecutionContext::minimumDOMTimerInterval):
(WebCore::ScriptExecutionContext::timerAlignmentInterval):
* dom/ScriptExecutionContext.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didInstallTimerImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::didInstallTimer):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::didInstallTimer):
* inspector/InspectorTimelineAgent.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::createTimerInstallData):
* inspector/TimelineRecordFactory.h:
* page/DOMTimer.cpp:
(WebCore::shouldForwardUserGesture):
(WebCore::userGestureTokenToForward):
(WebCore::DOMTimer::DOMTimer):
(WebCore::DOMTimer::install):
(WebCore::DOMTimer::intervalClampedToMinimum):
(WebCore::DOMTimer::alignedFireTime):
* page/DOMTimer.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::setTimeout):
(WebCore::DOMWindow::setInterval):
* page/Page.cpp:
(WebCore::Page::setTimerThrottlingState):
(WebCore::Page::setDOMTimerAlignmentIntervalIncreaseLimit):
(WebCore::Page::updateDOMTimerAlignmentInterval):
* page/Page.h:
(WebCore::Page::domTimerAlignmentInterval):
* page/Settings.cpp:
(WebCore::Settings::setMinimumDOMTimerInterval):
* page/Settings.h:
(WebCore::Settings::minimumDOMTimerInterval):
* page/SuspendableTimer.h:
(WebCore::SuspendableTimer::startRepeating):
(WebCore::SuspendableTimer::startOneShot):
(WebCore::SuspendableTimer::augmentFireInterval):
(WebCore::SuspendableTimer::augmentRepeatInterval):
* platform/Timer.cpp:
(WebCore::TimerBase::setNextFireTime):
* platform/Timer.h:
(WebCore::TimerBase::alignedFireTime):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setMinimumTimerInterval):
* testing/InternalSettings.h:
* testing/Internals.cpp:
(WebCore::Internals::isTimerThrottled):
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::setTimeout):
(WebCore::WorkerGlobalScope::setInterval):

Source/WebKit2:

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::updateHiddenPageThrottlingAutoIncreaseLimit):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::setHiddenPageDOMTimerThrottlingIncreaseLimit):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::setHiddenPageDOMTimerThrottlingIncreaseLimit):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213519 268f45cc-cd09-0410-ab3c-d52691b4dbfc

32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebCore/inspector/TimelineRecordFactory.cpp
Source/WebCore/inspector/TimelineRecordFactory.h
Source/WebCore/page/DOMTimer.cpp
Source/WebCore/page/DOMTimer.h
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebCore/page/SuspendableTimer.h
Source/WebCore/platform/Timer.cpp
Source/WebCore/platform/Timer.h
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in

index 66f1eec..abc3134 100644 (file)
@@ -1,5 +1,70 @@
 2017-03-07  Chris Dumez  <cdumez@apple.com>
 
+        Port DOMTimer from std::chrono::milliseconds to WTF::Seconds type
+        https://bugs.webkit.org/show_bug.cgi?id=169236
+
+        Reviewed by Simon Fraser.
+
+        * dom/Document.cpp:
+        (WebCore::Document::minimumDOMTimerInterval):
+        (WebCore::Document::timerAlignmentInterval):
+        * dom/Document.h:
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::adjustMinimumDOMTimerInterval):
+        (WebCore::ScriptExecutionContext::minimumDOMTimerInterval):
+        (WebCore::ScriptExecutionContext::timerAlignmentInterval):
+        * dom/ScriptExecutionContext.h:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didInstallTimerImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::didInstallTimer):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::didInstallTimer):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore::TimelineRecordFactory::createTimerInstallData):
+        * inspector/TimelineRecordFactory.h:
+        * page/DOMTimer.cpp:
+        (WebCore::shouldForwardUserGesture):
+        (WebCore::userGestureTokenToForward):
+        (WebCore::DOMTimer::DOMTimer):
+        (WebCore::DOMTimer::install):
+        (WebCore::DOMTimer::intervalClampedToMinimum):
+        (WebCore::DOMTimer::alignedFireTime):
+        * page/DOMTimer.h:
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::setTimeout):
+        (WebCore::DOMWindow::setInterval):
+        * page/Page.cpp:
+        (WebCore::Page::setTimerThrottlingState):
+        (WebCore::Page::setDOMTimerAlignmentIntervalIncreaseLimit):
+        (WebCore::Page::updateDOMTimerAlignmentInterval):
+        * page/Page.h:
+        (WebCore::Page::domTimerAlignmentInterval):
+        * page/Settings.cpp:
+        (WebCore::Settings::setMinimumDOMTimerInterval):
+        * page/Settings.h:
+        (WebCore::Settings::minimumDOMTimerInterval):
+        * page/SuspendableTimer.h:
+        (WebCore::SuspendableTimer::startRepeating):
+        (WebCore::SuspendableTimer::startOneShot):
+        (WebCore::SuspendableTimer::augmentFireInterval):
+        (WebCore::SuspendableTimer::augmentRepeatInterval):
+        * platform/Timer.cpp:
+        (WebCore::TimerBase::setNextFireTime):
+        * platform/Timer.h:
+        (WebCore::TimerBase::alignedFireTime):
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::setMinimumTimerInterval):
+        * testing/InternalSettings.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::isTimerThrottled):
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::setTimeout):
+        (WebCore::WorkerGlobalScope::setInterval):
+
+2017-03-07  Chris Dumez  <cdumez@apple.com>
+
         Align initEvent / initCustomEvent / initMessageEvent with the latest specification
         https://bugs.webkit.org/show_bug.cgi?id=169176
 
index f4b7561..57c3946 100644 (file)
@@ -2843,11 +2843,11 @@ void Document::writeln(const String& text, Document* ownerDocument)
     write(WTFMove(textWithNewline), ownerDocument);
 }
 
-std::chrono::milliseconds Document::minimumTimerInterval() const
+Seconds Document::minimumDOMTimerInterval() const
 {
     auto* page = this->page();
     if (!page)
-        return ScriptExecutionContext::minimumTimerInterval();
+        return ScriptExecutionContext::minimumDOMTimerInterval();
     return page->settings().minimumDOMTimerInterval();
 }
 
@@ -2860,9 +2860,9 @@ void Document::setTimerThrottlingEnabled(bool shouldThrottle)
     didChangeTimerAlignmentInterval();
 }
 
-std::chrono::milliseconds Document::timerAlignmentInterval(bool hasReachedMaxNestingLevel) const
+Seconds Document::domTimerAlignmentInterval(bool hasReachedMaxNestingLevel) const
 {
-    auto alignmentInterval = ScriptExecutionContext::timerAlignmentInterval(hasReachedMaxNestingLevel);
+    auto alignmentInterval = ScriptExecutionContext::domTimerAlignmentInterval(hasReachedMaxNestingLevel);
     if (!hasReachedMaxNestingLevel)
         return alignmentInterval;
 
index ff192b3..5c59c67 100644 (file)
@@ -1327,9 +1327,9 @@ private:
 
     void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0) final;
 
-    std::chrono::milliseconds minimumTimerInterval() const final;
+    Seconds minimumDOMTimerInterval() const final;
 
-    std::chrono::milliseconds timerAlignmentInterval(bool hasReachedMaxNestingLevel) const final;
+    Seconds domTimerAlignmentInterval(bool hasReachedMaxNestingLevel) const final;
 
     void updateTitleFromTitleElement();
     void updateTitle(const StringWithDirection&);
index 328818f..f3aaf60 100644 (file)
@@ -427,15 +427,15 @@ PublicURLManager& ScriptExecutionContext::publicURLManager()
     return *m_publicURLManager;
 }
 
-void ScriptExecutionContext::adjustMinimumTimerInterval(std::chrono::milliseconds oldMinimumTimerInterval)
+void ScriptExecutionContext::adjustMinimumDOMTimerInterval(Seconds oldMinimumTimerInterval)
 {
-    if (minimumTimerInterval() != oldMinimumTimerInterval) {
+    if (minimumDOMTimerInterval() != oldMinimumTimerInterval) {
         for (auto& timer : m_timeouts.values())
             timer->updateTimerIntervalIfNecessary();
     }
 }
 
-std::chrono::milliseconds ScriptExecutionContext::minimumTimerInterval() const
+Seconds ScriptExecutionContext::minimumDOMTimerInterval() const
 {
     // The default implementation returns the DOMTimer's default
     // minimum timer interval. FIXME: to make it work with dedicated
@@ -451,7 +451,7 @@ void ScriptExecutionContext::didChangeTimerAlignmentInterval()
         timer->didChangeAlignmentInterval();
 }
 
-std::chrono::milliseconds ScriptExecutionContext::timerAlignmentInterval(bool) const
+Seconds ScriptExecutionContext::domTimerAlignmentInterval(bool) const
 {
     return DOMTimer::defaultAlignmentInterval();
 }
index ddf3471..405147b 100644 (file)
@@ -189,12 +189,11 @@ public:
 
     WEBCORE_EXPORT JSC::VM& vm();
 
-    // Interval is in seconds.
-    void adjustMinimumTimerInterval(std::chrono::milliseconds oldMinimumTimerInterval);
-    virtual std::chrono::milliseconds minimumTimerInterval() const;
+    void adjustMinimumDOMTimerInterval(Seconds oldMinimumTimerInterval);
+    virtual Seconds minimumDOMTimerInterval() const;
 
     void didChangeTimerAlignmentInterval();
-    virtual std::chrono::milliseconds timerAlignmentInterval(bool hasReachedMaxNestingLevel) const;
+    virtual Seconds domTimerAlignmentInterval(bool hasReachedMaxNestingLevel) const;
 
     virtual EventQueue& eventQueue() const = 0;
 
index 70f22af..580a828 100644 (file)
@@ -336,7 +336,7 @@ void InspectorInstrumentation::willSendXMLHttpRequestImpl(InstrumentingAgents& i
         domDebuggerAgent->willSendXMLHttpRequest(url);
 }
 
-void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, std::chrono::milliseconds timeout, bool singleShot, ScriptExecutionContext& context)
+void InspectorInstrumentation::didInstallTimerImpl(InstrumentingAgents& instrumentingAgents, int timerId, Seconds timeout, bool singleShot, ScriptExecutionContext& context)
 {
     pauseOnNativeEventIfNeeded(instrumentingAgents, false, setTimerEventName, true);
     didScheduleAsyncCall(instrumentingAgents, AsyncCallTypeTimer, timerId, context, singleShot);
index 9e0e0ab..c9db4ff 100644 (file)
@@ -123,7 +123,7 @@ public:
     static bool forcePseudoState(const Element&, CSSSelector::PseudoClassType);
 
     static void willSendXMLHttpRequest(ScriptExecutionContext*, const String& url);
-    static void didInstallTimer(ScriptExecutionContext&, int timerId, std::chrono::milliseconds timeout, bool singleShot);
+    static void didInstallTimer(ScriptExecutionContext&, int timerId, Seconds timeout, bool singleShot);
     static void didRemoveTimer(ScriptExecutionContext&, int timerId);
 
     static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine);
@@ -293,7 +293,7 @@ private:
     static bool forcePseudoStateImpl(InstrumentingAgents&, const Element&, CSSSelector::PseudoClassType);
 
     static void willSendXMLHttpRequestImpl(InstrumentingAgents&, const String& url);
-    static void didInstallTimerImpl(InstrumentingAgents&, int timerId, std::chrono::milliseconds timeout, bool singleShot, ScriptExecutionContext&);
+    static void didInstallTimerImpl(InstrumentingAgents&, int timerId, Seconds timeout, bool singleShot, ScriptExecutionContext&);
     static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext&);
 
     static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents&, const String& scriptName, int scriptLine, ScriptExecutionContext*);
@@ -642,7 +642,7 @@ inline void InspectorInstrumentation::willSendXMLHttpRequest(ScriptExecutionCont
         willSendXMLHttpRequestImpl(*instrumentingAgents, url);
 }
 
-inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext& context, int timerId, std::chrono::milliseconds timeout, bool singleShot)
+inline void InspectorInstrumentation::didInstallTimer(ScriptExecutionContext& context, int timerId, Seconds timeout, bool singleShot)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
index 1f0d057..e202d32 100644 (file)
@@ -384,7 +384,7 @@ void InspectorTimelineAgent::didPaint(RenderObject& renderer, const LayoutRect&
     didCompleteCurrentRecord(TimelineRecordType::Paint);
 }
 
-void InspectorTimelineAgent::didInstallTimer(int timerId, std::chrono::milliseconds timeout, bool singleShot, Frame* frame)
+void InspectorTimelineAgent::didInstallTimer(int timerId, Seconds timeout, bool singleShot, Frame* frame)
 {
     appendRecord(TimelineRecordFactory::createTimerInstallData(timerId, timeout, singleShot), TimelineRecordType::TimerInstall, true, frame);
 }
index bf5bbbb..85f06da 100644 (file)
@@ -112,7 +112,7 @@ public:
     void stopFromConsole(JSC::ExecState*, const String& title);
 
     // InspectorInstrumentation
-    void didInstallTimer(int timerId, std::chrono::milliseconds timeout, bool singleShot, Frame*);
+    void didInstallTimer(int timerId, Seconds timeout, bool singleShot, Frame*);
     void didRemoveTimer(int timerId, Frame*);
     void willFireTimer(int timerId, Frame*);
     void didFireTimer();
index a216593..74aa7ff 100644 (file)
@@ -94,11 +94,11 @@ Ref<InspectorObject> TimelineRecordFactory::createGenericTimerData(int timerId)
     return data;
 }
 
-Ref<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, std::chrono::milliseconds timeout, bool singleShot)
+Ref<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, Seconds timeout, bool singleShot)
 {
     Ref<InspectorObject> data = InspectorObject::create();
     data->setInteger(ASCIILiteral("timerId"), timerId);
-    data->setInteger(ASCIILiteral("timeout"), (int)timeout.count());
+    data->setInteger(ASCIILiteral("timeout"), (int)timeout.milliseconds());
     data->setBoolean(ASCIILiteral("singleShot"), singleShot);
     return data;
 }
index fb705d1..ddf8d05 100644 (file)
@@ -53,7 +53,7 @@ public:
     static Ref<Inspector::InspectorObject> createProbeSampleData(const Inspector::ScriptBreakpointAction&, unsigned sampleId);
     static Ref<Inspector::InspectorObject> createEventDispatchData(const Event&);
     static Ref<Inspector::InspectorObject> createGenericTimerData(int timerId);
-    static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, std::chrono::milliseconds timeout, bool singleShot);
+    static Ref<Inspector::InspectorObject> createTimerInstallData(int timerId, Seconds timeout, bool singleShot);
     static Ref<Inspector::InspectorObject> createEvaluateScriptData(const String&, double lineNumber);
     static Ref<Inspector::InspectorObject> createTimeStampData(const String&);
     static Ref<Inspector::InspectorObject> createAnimationFrameData(int callbackId);
index 80e1b8d..1f80c69 100644 (file)
@@ -52,8 +52,8 @@
 
 namespace WebCore {
 
-static const auto maxIntervalForUserGestureForwarding = 1000ms; // One second matches Gecko.
-static const auto minIntervalForNonUserObservableChangeTimers = 1000ms; // Empirically determined to maximize battery life.
+static const Seconds maxIntervalForUserGestureForwarding { 1_s }; // One second matches Gecko.
+static const Seconds minIntervalForNonUserObservableChangeTimers { 1_s }; // Empirically determined to maximize battery life.
 static const int maxTimerNestingLevel = 5;
 
 class DOMTimerFireState {
@@ -161,14 +161,14 @@ private:
 
 bool NestedTimersMap::isTrackingNestedTimers = false;
 
-static inline bool shouldForwardUserGesture(std::chrono::milliseconds interval, int nestingLevel)
+static inline bool shouldForwardUserGesture(Seconds interval, int nestingLevel)
 {
     return UserGestureIndicator::processingUserGesture()
         && interval <= maxIntervalForUserGestureForwarding
         && !nestingLevel; // Gestures should not be forwarded to nested timers.
 }
 
-static inline RefPtr<UserGestureToken> userGestureTokenToForward(std::chrono::milliseconds interval, int nestingLevel)
+static inline RefPtr<UserGestureToken> userGestureTokenToForward(Seconds interval, int nestingLevel)
 {
     if (!shouldForwardUserGesture(interval, nestingLevel))
         return nullptr;
@@ -176,7 +176,7 @@ static inline RefPtr<UserGestureToken> userGestureTokenToForward(std::chrono::mi
     return UserGestureIndicator::currentUserGesture();
 }
 
-DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, std::chrono::milliseconds interval, bool singleShot)
+DOMTimer::DOMTimer(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, Seconds interval, bool singleShot)
     : SuspendableTimer(context)
     , m_nestingLevel(context.timerNestingLevel())
     , m_action(WTFMove(action))
@@ -202,7 +202,7 @@ DOMTimer::~DOMTimer()
 {
 }
 
-int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, std::chrono::milliseconds timeout, bool singleShot)
+int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<ScheduledAction> action, Seconds timeout, bool singleShot)
 {
     // DOMTimer constructor passes ownership of the initial ref on the object to the constructor.
     // This reference will be released automatically when a one-shot timer fires, when the context
@@ -211,7 +211,7 @@ int DOMTimer::install(ScriptExecutionContext& context, std::unique_ptr<Scheduled
 #if PLATFORM(IOS)
     if (is<Document>(context)) {
         bool didDeferTimeout = context.activeDOMObjectsAreSuspended();
-        if (!didDeferTimeout && timeout.count() <= 100 && singleShot) {
+        if (!didDeferTimeout && timeout <= 100_ms && singleShot) {
             WKSetObservedContentChange(WKContentIndeterminateChange);
             WebThreadAddObservedContentModifier(timer); // Will only take affect if not already visibility change.
         }
@@ -400,45 +400,45 @@ void DOMTimer::updateTimerIntervalIfNecessary()
         return;
 
     if (repeatInterval()) {
-        ASSERT(repeatIntervalMS() == previousInterval);
-        LOG(DOMTimers, "%p - Updating DOMTimer's repeat interval from %" PRId64 " ms to %" PRId64 " ms due to throttling.", this, previousInterval.count(), m_currentTimerInterval.count());
+        ASSERT(repeatIntervalSeconds() == previousInterval);
+        LOG(DOMTimers, "%p - Updating DOMTimer's repeat interval from %.2f ms to %.2f ms due to throttling.", this, previousInterval.milliseconds(), m_currentTimerInterval.milliseconds());
         augmentRepeatInterval(m_currentTimerInterval - previousInterval);
     } else {
-        LOG(DOMTimers, "%p - Updating DOMTimer's fire interval from %" PRId64 " ms to %" PRId64 " ms due to throttling.", this, previousInterval.count(), m_currentTimerInterval.count());
+        LOG(DOMTimers, "%p - Updating DOMTimer's fire interval from %.2f ms to %.2f ms due to throttling.", this, previousInterval.milliseconds(), m_currentTimerInterval.milliseconds());
         augmentFireInterval(m_currentTimerInterval - previousInterval);
     }
 }
 
-std::chrono::milliseconds DOMTimer::intervalClampedToMinimum() const
+Seconds DOMTimer::intervalClampedToMinimum() const
 {
     ASSERT(scriptExecutionContext());
     ASSERT(m_nestingLevel <= maxTimerNestingLevel);
 
-    auto interval = std::max(1ms, m_originalInterval);
+    Seconds interval = std::max(1_ms, m_originalInterval);
 
     // Only apply throttling to repeating timers.
     if (m_nestingLevel < maxTimerNestingLevel)
         return interval;
 
     // Apply two throttles - the global (per Page) minimum, and also a per-timer throttle.
-    interval = std::max(interval, scriptExecutionContext()->minimumTimerInterval());
+    interval = std::max(interval, scriptExecutionContext()->minimumDOMTimerInterval());
     if (m_throttleState == ShouldThrottle)
         interval = std::max(interval, minIntervalForNonUserObservableChangeTimers);
     return interval;
 }
 
-std::optional<std::chrono::milliseconds> DOMTimer::alignedFireTime(std::chrono::milliseconds fireTime) const
+std::optional<Seconds> DOMTimer::alignedFireTime(Seconds fireTime) const
 {
-    auto alignmentInterval = scriptExecutionContext()->timerAlignmentInterval(m_nestingLevel >= maxTimerNestingLevel);
-    if (alignmentInterval == 0ms)
+    Seconds alignmentInterval = scriptExecutionContext()->domTimerAlignmentInterval(m_nestingLevel >= maxTimerNestingLevel);
+    if (!alignmentInterval)
         return std::nullopt;
     
     static const double randomizedProportion = randomNumber();
 
     // Force alignment to randomizedAlignment fraction of the way between alignemntIntervals, e.g.
-    // if alignmentInterval is 10 and randomizedAlignment is 0.3 this will align to 3, 13, 23, ...
-    auto randomizedOffset = std::chrono::duration_cast<std::chrono::milliseconds>(alignmentInterval * randomizedProportion);
-    auto adjustedFireTime = fireTime - randomizedOffset;
+    // if alignmentInterval is 10_ms and randomizedAlignment is 0.3 this will align to 3, 13, 23, ...
+    Seconds randomizedOffset = alignmentInterval * randomizedProportion;
+    Seconds adjustedFireTime = fireTime - randomizedOffset;
     return adjustedFireTime - (adjustedFireTime % alignmentInterval) + alignmentInterval + randomizedOffset;
 }
 
index 8727739..dbc7d34 100644 (file)
@@ -30,6 +30,7 @@
 #include "UserGestureIndicator.h"
 #include <memory>
 #include <wtf/RefCounted.h>
+#include <wtf/Seconds.h>
 
 namespace WebCore {
 
@@ -44,13 +45,13 @@ class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimer {
 public:
     virtual ~DOMTimer();
 
-    static std::chrono::milliseconds defaultMinimumInterval() { return 4ms; }
-    static std::chrono::milliseconds defaultAlignmentInterval() { return 0ms; }
-    static std::chrono::milliseconds hiddenPageAlignmentInterval() { return 1000ms; }
+    static Seconds defaultMinimumInterval() { return 4_ms; }
+    static Seconds defaultAlignmentInterval() { return 0_s; }
+    static Seconds hiddenPageAlignmentInterval() { return 1_s; }
 
     // Creates a new timer owned by specified ScriptExecutionContext, starts it
     // and returns its Id.
-    static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, std::chrono::milliseconds timeout, bool singleShot);
+    static int install(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, Seconds timeout, bool singleShot);
     static void removeById(ScriptExecutionContext&, int timeoutId);
 
     // Notify that the interval may need updating (e.g. because the minimum interval
@@ -60,10 +61,10 @@ public:
     static void scriptDidInteractWithPlugin(HTMLPlugInElement&);
 
 private:
-    DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, std::chrono::milliseconds interval, bool singleShot);
+    DOMTimer(ScriptExecutionContext&, std::unique_ptr<ScheduledAction>, Seconds interval, bool singleShot);
     friend class Internals;
 
-    WEBCORE_EXPORT std::chrono::milliseconds intervalClampedToMinimum() const;
+    WEBCORE_EXPORT Seconds intervalClampedToMinimum() const;
 
     bool isDOMTimersThrottlingEnabled(Document&) const;
     void updateThrottlingStateIfNecessary(const DOMTimerFireState&);
@@ -71,7 +72,7 @@ private:
     // SuspendableTimer
     void fired() override;
     void didStop() override;
-    WEBCORE_EXPORT std::optional<std::chrono::milliseconds> alignedFireTime(std::chrono::milliseconds) const override;
+    WEBCORE_EXPORT std::optional<Seconds> alignedFireTime(Seconds) const override;
 
     // ActiveDOMObject API.
     const char* activeDOMObjectName() const override;
@@ -85,9 +86,9 @@ private:
     int m_timeoutId;
     int m_nestingLevel;
     std::unique_ptr<ScheduledAction> m_action;
-    std::chrono::milliseconds m_originalInterval;
+    Seconds m_originalInterval;
     TimerThrottleState m_throttleState;
-    std::chrono::milliseconds m_currentTimerInterval;
+    Seconds m_currentTimerInterval;
     RefPtr<UserGestureToken> m_userGestureTokenToForward;
 };
 
index 6aedb09..e2b38a5 100644 (file)
@@ -1663,7 +1663,7 @@ ExceptionOr<int> DOMWindow::setTimeout(std::unique_ptr<ScheduledAction> action,
     auto* context = scriptExecutionContext();
     if (!context)
         return Exception { INVALID_ACCESS_ERR };
-    return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), true);
+    return DOMTimer::install(*context, WTFMove(action), Seconds::fromMilliseconds(timeout), true);
 }
 
 void DOMWindow::clearTimeout(int timeoutId)
@@ -1695,7 +1695,7 @@ ExceptionOr<int> DOMWindow::setInterval(std::unique_ptr<ScheduledAction> action,
     auto* context = scriptExecutionContext();
     if (!context)
         return Exception { INVALID_ACCESS_ERR };
-    return DOMTimer::install(*context, WTFMove(action), std::chrono::milliseconds(timeout), false);
+    return DOMTimer::install(*context, WTFMove(action), Seconds::fromMilliseconds(timeout), false);
 }
 
 void DOMWindow::clearInterval(int timeoutId)
index 7d6d98a..24694d8 100644 (file)
@@ -234,8 +234,8 @@ Page::Page(PageConfiguration&& pageConfiguration)
 #if ENABLE(VIEW_MODE_CSS_MEDIA)
     , m_viewMode(ViewModeWindowed)
 #endif // ENABLE(VIEW_MODE_CSS_MEDIA)
-    , m_timerAlignmentInterval(DOMTimer::defaultAlignmentInterval())
-    , m_timerAlignmentIntervalIncreaseTimer(*this, &Page::timerAlignmentIntervalIncreaseTimerFired)
+    , m_domTimerAlignmentInterval(DOMTimer::defaultAlignmentInterval())
+    , m_domTimerAlignmentIntervalIncreaseTimer(*this, &Page::domTimerAlignmentIntervalIncreaseTimerFired)
     , m_isEditable(false)
     , m_isPrerender(false)
     , m_activityState(PageInitialActivityState)
@@ -1320,7 +1320,7 @@ void Page::setTimerThrottlingState(TimerThrottlingState state)
         return;
 
     m_timerThrottlingState = state;
-    m_timerThrottlingStateLastChangedTime = std::chrono::steady_clock::now();
+    m_timerThrottlingStateLastChangedTime = MonotonicTime::now();
 
     updateDOMTimerAlignmentInterval();
 
@@ -1333,12 +1333,12 @@ void Page::setTimerThrottlingState(TimerThrottlingState state)
     }
 }
 
-void Page::setTimerAlignmentIntervalIncreaseLimit(std::chrono::milliseconds limit)
+void Page::setDOMTimerAlignmentIntervalIncreaseLimit(Seconds limit)
 {
-    m_timerAlignmentIntervalIncreaseLimit = limit;
+    m_domTimerAlignmentIntervalIncreaseLimit = limit;
 
-    // If (m_timerAlignmentIntervalIncreaseLimit < m_timerAlignmentInterval) then we need
-    // to update m_timerAlignmentInterval, if greater then need to restart the increase timer.
+    // If (m_domTimerAlignmentIntervalIncreaseLimit < m_domTimerAlignmentInterval) then we need
+    // to update m_domTimerAlignmentInterval, if greater then need to restart the increase timer.
     if (m_timerThrottlingState == TimerThrottlingState::EnabledIncreasing)
         updateDOMTimerAlignmentInterval();
 }
@@ -1349,28 +1349,28 @@ void Page::updateDOMTimerAlignmentInterval()
 
     switch (m_timerThrottlingState) {
     case TimerThrottlingState::Disabled:
-        m_timerAlignmentInterval = DOMTimer::defaultAlignmentInterval();
+        m_domTimerAlignmentInterval = DOMTimer::defaultAlignmentInterval();
         break;
 
     case TimerThrottlingState::Enabled:
-        m_timerAlignmentInterval = DOMTimer::hiddenPageAlignmentInterval();
+        m_domTimerAlignmentInterval = DOMTimer::hiddenPageAlignmentInterval();
         break;
 
     case TimerThrottlingState::EnabledIncreasing:
         // For pages in prerender state maximum throttling kicks in immediately.
         if (m_isPrerender)
-            m_timerAlignmentInterval = m_timerAlignmentIntervalIncreaseLimit;
+            m_domTimerAlignmentInterval = m_domTimerAlignmentIntervalIncreaseLimit;
         else {
-            ASSERT(m_timerThrottlingStateLastChangedTime.time_since_epoch() != std::chrono::steady_clock::duration::zero());
-            m_timerAlignmentInterval = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - m_timerThrottlingStateLastChangedTime);
+            ASSERT(!!m_timerThrottlingStateLastChangedTime);
+            m_domTimerAlignmentInterval = MonotonicTime::now() - m_timerThrottlingStateLastChangedTime;
             // If we're below the limit, set the timer. If above, clamp to limit.
-            if (m_timerAlignmentInterval < m_timerAlignmentIntervalIncreaseLimit)
+            if (m_domTimerAlignmentInterval < m_domTimerAlignmentIntervalIncreaseLimit)
                 needsIncreaseTimer = true;
             else
-                m_timerAlignmentInterval = m_timerAlignmentIntervalIncreaseLimit;
+                m_domTimerAlignmentInterval = m_domTimerAlignmentIntervalIncreaseLimit;
         }
         // Alignment interval should not be less than DOMTimer::hiddenPageAlignmentInterval().
-        m_timerAlignmentInterval = std::max(m_timerAlignmentInterval, DOMTimer::hiddenPageAlignmentInterval());
+        m_domTimerAlignmentInterval = std::max(m_domTimerAlignmentInterval, DOMTimer::hiddenPageAlignmentInterval());
     }
 
     // If throttling is enabled, auto-increasing of throttling is enabled, and the auto-increase
@@ -1378,16 +1378,16 @@ void Page::updateDOMTimerAlignmentInterval()
     // between increases is equal to the current throttle time. Since alinment interval increases
     // exponentially, time between steps is exponential too.
     if (!needsIncreaseTimer)
-        m_timerAlignmentIntervalIncreaseTimer.stop();
-    else if (!m_timerAlignmentIntervalIncreaseTimer.isActive())
-        m_timerAlignmentIntervalIncreaseTimer.startOneShot(m_timerAlignmentInterval);
+        m_domTimerAlignmentIntervalIncreaseTimer.stop();
+    else if (!m_domTimerAlignmentIntervalIncreaseTimer.isActive())
+        m_domTimerAlignmentIntervalIncreaseTimer.startOneShot(m_domTimerAlignmentInterval);
 }
 
-void Page::timerAlignmentIntervalIncreaseTimerFired()
+void Page::domTimerAlignmentIntervalIncreaseTimerFired()
 {
     ASSERT(m_settings->hiddenPageDOMTimerThrottlingAutoIncreases());
     ASSERT(m_timerThrottlingState == TimerThrottlingState::EnabledIncreasing);
-    ASSERT(m_timerAlignmentInterval < m_timerAlignmentIntervalIncreaseLimit);
+    ASSERT(m_domTimerAlignmentInterval < m_domTimerAlignmentIntervalIncreaseLimit);
     
     // Alignment interval is increased to equal the time the page has been throttled, to a limit.
     updateDOMTimerAlignmentInterval();
index 938a096..f86f47e 100644 (file)
@@ -240,7 +240,7 @@ public:
     ProgressTracker& progress() const { return *m_progress; }
     BackForwardController& backForward() const { return *m_backForwardController; }
 
-    std::chrono::milliseconds domTimerAlignmentInterval() const { return m_timerAlignmentInterval; }
+    Seconds domTimerAlignmentInterval() const { return m_domTimerAlignmentInterval; }
 
 #if ENABLE(VIEW_MODE_CSS_MEDIA)
     enum ViewMode {
@@ -552,7 +552,7 @@ public:
     void setShowAllPlugins(bool showAll) { m_showAllPlugins = showAll; }
     bool showAllPlugins() const;
 
-    WEBCORE_EXPORT void setTimerAlignmentIntervalIncreaseLimit(std::chrono::milliseconds);
+    WEBCORE_EXPORT void setDOMTimerAlignmentIntervalIncreaseLimit(Seconds);
 
     bool isControlledByAutomation() const { return m_controlledByAutomation; }
     void setControlledByAutomation(bool controlled) { m_controlledByAutomation = controlled; }
@@ -609,7 +609,7 @@ private:
     void setTimerThrottlingState(TimerThrottlingState);
     void updateTimerThrottlingState();
     void updateDOMTimerAlignmentInterval();
-    void timerAlignmentIntervalIncreaseTimerFired();
+    void domTimerAlignmentIntervalIncreaseTimerFired();
 
     const std::unique_ptr<Chrome> m_chrome;
     const std::unique_ptr<DragCaretController> m_dragCaretController;
@@ -712,10 +712,10 @@ private:
 #endif // ENABLE(VIEW_MODE_CSS_MEDIA)
 
     TimerThrottlingState m_timerThrottlingState { TimerThrottlingState::Disabled };
-    std::chrono::steady_clock::time_point m_timerThrottlingStateLastChangedTime { std::chrono::steady_clock::duration::zero() };
-    std::chrono::milliseconds m_timerAlignmentInterval;
-    Timer m_timerAlignmentIntervalIncreaseTimer;
-    std::chrono::milliseconds m_timerAlignmentIntervalIncreaseLimit { 0 };
+    MonotonicTime m_timerThrottlingStateLastChangedTime;
+    Seconds m_domTimerAlignmentInterval;
+    Timer m_domTimerAlignmentIntervalIncreaseTimer;
+    Seconds m_domTimerAlignmentIntervalIncreaseLimit;
 
     bool m_isEditable;
     bool m_isPrerender;
index 6bb9d03..7d08784 100644 (file)
@@ -449,17 +449,16 @@ void Settings::setNeedsAdobeFrameReloadingQuirk(bool shouldNotReloadIFramesForUn
     m_needsAdobeFrameReloadingQuirk = shouldNotReloadIFramesForUnchangedSRC;
 }
 
-void Settings::setMinimumDOMTimerInterval(std::chrono::milliseconds interval)
+void Settings::setMinimumDOMTimerInterval(Seconds interval)
 {
-    auto oldTimerInterval = m_minimumDOMTimerInterval;
-    m_minimumDOMTimerInterval = interval;
+    auto oldTimerInterval = std::exchange(m_minimumDOMTimerInterval, interval);
 
     if (!m_page)
         return;
 
     for (Frame* frame = &m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
         if (frame->document())
-            frame->document()->adjustMinimumTimerInterval(oldTimerInterval);
+            frame->document()->adjustMinimumDOMTimerInterval(oldTimerInterval);
     }
 }
 
index 7fc5708..9f37075 100644 (file)
@@ -169,8 +169,8 @@ public:
     WEBCORE_EXPORT void setNeedsAdobeFrameReloadingQuirk(bool);
     bool needsAcrobatFrameReloadingQuirk() const { return m_needsAdobeFrameReloadingQuirk; }
 
-    WEBCORE_EXPORT void setMinimumDOMTimerInterval(std::chrono::milliseconds); // Initialized to DOMTimer::defaultMinimumInterval().
-    std::chrono::milliseconds minimumDOMTimerInterval() const { return m_minimumDOMTimerInterval; }
+    WEBCORE_EXPORT void setMinimumDOMTimerInterval(Seconds); // Initialized to DOMTimer::defaultMinimumInterval().
+    Seconds minimumDOMTimerInterval() const { return m_minimumDOMTimerInterval; }
 
     WEBCORE_EXPORT void setLayoutInterval(Seconds);
     Seconds layoutInterval() const { return m_layoutInterval; }
@@ -338,7 +338,7 @@ private:
     const std::unique_ptr<FontGenericFamilies> m_fontGenericFamilies;
     SecurityOrigin::StorageBlockingPolicy m_storageBlockingPolicy;
     Seconds m_layoutInterval;
-    std::chrono::milliseconds m_minimumDOMTimerInterval;
+    Seconds m_minimumDOMTimerInterval;
 
     SETTINGS_MEMBER_VARIABLES
 
index e15f0a7..bada7bc 100644 (file)
@@ -29,6 +29,8 @@
 #include "ActiveDOMObject.h"
 #include "Timer.h"
 
+#include <wtf/Seconds.h>
+
 namespace WebCore {
 
 class SuspendableTimer : private TimerBase, public ActiveDOMObject {
@@ -49,9 +51,20 @@ public:
     void augmentFireInterval(double delta);
     void augmentRepeatInterval(double delta);
 
+    void startRepeating(Seconds repeatInterval) { startRepeating(repeatInterval.value()); }
+    void startOneShot(Seconds interval) { startOneShot(interval.value()); }
+
+    // FIXME: Use the overloads taking Seconds instead and drop these.
     void startRepeating(std::chrono::milliseconds repeatInterval) { startRepeating(msToSeconds(repeatInterval)); }
     void startOneShot(std::chrono::milliseconds interval) { startOneShot(msToSeconds(interval)); }
+
     std::chrono::milliseconds repeatIntervalMS() const { return secondsToMS(repeatInterval()); }
+    Seconds repeatIntervalSeconds() const { return Seconds { repeatInterval() }; }
+
+    void augmentFireInterval(Seconds delta) { augmentFireInterval(delta.value()); }
+    void augmentRepeatInterval(Seconds delta) { augmentRepeatInterval(delta.value()); }
+
+    // FIXME: Use the overloads taking Seconds instead and drop these.
     void augmentFireInterval(std::chrono::milliseconds delta) { augmentFireInterval(msToSeconds(delta)); }
     void augmentRepeatInterval(std::chrono::milliseconds delta) { augmentRepeatInterval(msToSeconds(delta)); }
 
index cd594fe..0a42667 100644 (file)
@@ -382,8 +382,8 @@ void TimerBase::setNextFireTime(double newTime)
     double oldTime = m_nextFireTime;
     // Don't realign zero-delay timers.
     if (newTime) {
-        if (auto newAlignedTime = alignedFireTime(secondsToMS(newTime)))
-            newTime = msToSeconds(newAlignedTime.value());
+        if (auto newAlignedTime = alignedFireTime(Seconds { newTime }))
+            newTime = newAlignedTime.value().seconds();
     }
 
     if (oldTime != newTime) {
index 52a166e..0477489 100644 (file)
@@ -88,7 +88,7 @@ public:
 private:
     virtual void fired() = 0;
 
-    virtual std::optional<std::chrono::milliseconds> alignedFireTime(std::chrono::milliseconds) const { return std::nullopt; }
+    virtual std::optional<Seconds> alignedFireTime(Seconds) const { return std::nullopt; }
 
     void checkConsistency() const;
     void checkHeapIndex() const;
index 4e24484..6661c91 100644 (file)
@@ -62,7 +62,7 @@ InternalSettings::Backup::Backup(Settings& settings)
     , m_originalMockScrollbarsEnabled(settings.mockScrollbarsEnabled())
     , m_imagesEnabled(settings.areImagesEnabled())
     , m_preferMIMETypeForImages(settings.preferMIMETypeForImages())
-    , m_minimumTimerInterval(settings.minimumDOMTimerInterval())
+    , m_minimumDOMTimerInterval(settings.minimumDOMTimerInterval())
 #if ENABLE(VIDEO_TRACK)
     , m_shouldDisplaySubtitles(settings.shouldDisplaySubtitles())
     , m_shouldDisplayCaptions(settings.shouldDisplayCaptions())
@@ -151,7 +151,7 @@ void InternalSettings::Backup::restoreTo(Settings& settings)
     settings.setCanvasUsesAcceleratedDrawing(m_originalCanvasUsesAcceleratedDrawing);
     settings.setImagesEnabled(m_imagesEnabled);
     settings.setPreferMIMETypeForImages(m_preferMIMETypeForImages);
-    settings.setMinimumDOMTimerInterval(m_minimumTimerInterval);
+    settings.setMinimumDOMTimerInterval(m_minimumDOMTimerInterval);
 #if ENABLE(VIDEO_TRACK)
     settings.setShouldDisplaySubtitles(m_shouldDisplaySubtitles);
     settings.setShouldDisplayCaptions(m_shouldDisplayCaptions);
@@ -544,7 +544,7 @@ ExceptionOr<void> InternalSettings::setMinimumTimerInterval(double intervalInSec
 {
     if (!m_page)
         return Exception { INVALID_ACCESS_ERR };
-    settings().setMinimumDOMTimerInterval(std::chrono::milliseconds((std::chrono::milliseconds::rep)(intervalInSeconds * 1000)));
+    settings().setMinimumDOMTimerInterval(Seconds { intervalInSeconds });
     return { };
 }
 
index 8a09f95..486c306 100644 (file)
@@ -148,7 +148,7 @@ private:
         bool m_originalUsesOverlayScrollbars;
         bool m_imagesEnabled;
         bool m_preferMIMETypeForImages;
-        std::chrono::milliseconds m_minimumTimerInterval;
+        Seconds m_minimumDOMTimerInterval;
 #if ENABLE(VIDEO_TRACK)
         bool m_shouldDisplaySubtitles;
         bool m_shouldDisplayCaptions;
index cadab72..b78f1dc 100644 (file)
@@ -1045,7 +1045,7 @@ ExceptionOr<bool> Internals::isTimerThrottled(int timeoutId)
     if (timer->intervalClampedToMinimum() > timer->m_originalInterval)
         return true;
 
-    return !!timer->alignedFireTime(0ms);
+    return !!timer->alignedFireTime(0_s);
 }
 
 bool Internals::isRequestAnimationFrameThrottled() const
index 9b35709..152415c 100644 (file)
@@ -207,7 +207,7 @@ void WorkerGlobalScope::postTask(Task&& task)
 
 int WorkerGlobalScope::setTimeout(std::unique_ptr<ScheduledAction> action, int timeout)
 {
-    return DOMTimer::install(*this, WTFMove(action), std::chrono::milliseconds(timeout), true);
+    return DOMTimer::install(*this, WTFMove(action), Seconds::fromMilliseconds(timeout), true);
 }
 
 void WorkerGlobalScope::clearTimeout(int timeoutId)
@@ -217,7 +217,7 @@ void WorkerGlobalScope::clearTimeout(int timeoutId)
 
 int WorkerGlobalScope::setInterval(std::unique_ptr<ScheduledAction> action, int timeout)
 {
-    return DOMTimer::install(*this, WTFMove(action), std::chrono::milliseconds(timeout), false);
+    return DOMTimer::install(*this, WTFMove(action), Seconds::fromMilliseconds(timeout), false);
 }
 
 void WorkerGlobalScope::clearInterval(int timeoutId)
index 9660660..3175be3 100644 (file)
@@ -7467,7 +7467,7 @@ HRESULT WebView::defaultMinimumTimerInterval(_Out_ double* interval)
 {
     if (!interval)
         return E_POINTER;
-    *interval = DOMTimer::defaultMinimumInterval().count() / 1000.;
+    *interval = DOMTimer::defaultMinimumInterval().seconds();
     return S_OK;
 }
 
@@ -7476,8 +7476,7 @@ HRESULT WebView::setMinimumTimerInterval(double interval)
     if (!m_page)
         return E_FAIL;
 
-    auto intervalMS = std::chrono::milliseconds((std::chrono::milliseconds::rep)(interval * 1000));
-    page()->settings().setMinimumDOMTimerInterval(intervalMS);
+    page()->settings().setMinimumDOMTimerInterval(Seconds { interval });
     return S_OK;
 }
 
index 5354332..8a1ce1a 100644 (file)
@@ -1,3 +1,19 @@
+2017-03-07  Chris Dumez  <cdumez@apple.com>
+
+        Port DOMTimer from std::chrono::milliseconds to WTF::Seconds type
+        https://bugs.webkit.org/show_bug.cgi?id=169236
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::updateHiddenPageThrottlingAutoIncreaseLimit):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::setHiddenPageDOMTimerThrottlingIncreaseLimit):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::setHiddenPageDOMTimerThrottlingIncreaseLimit):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
 2017-03-06  Aakash Jain  <aakash_jain@apple.com>
 
         Enable SUPPORTS_TEXT_BASED_API in WebKit2 for iOS
index 309156b..de3933f 100644 (file)
@@ -1465,7 +1465,7 @@ void WebProcessPool::updateHiddenPageThrottlingAutoIncreaseLimit()
     static int maximumTimerThrottlePerPageInMS = 200 * 100;
 
     int limitInMilliseconds = maximumTimerThrottlePerPageInMS * m_hiddenPageThrottlingAutoIncreasesCounter.value();
-    sendToAllProcesses(Messages::WebProcess::SetHiddenPageTimerThrottlingIncreaseLimit(limitInMilliseconds));
+    sendToAllProcesses(Messages::WebProcess::SetHiddenPageDOMTimerThrottlingIncreaseLimit(limitInMilliseconds));
 }
 
 void WebProcessPool::reportWebContentCPUTime(int64_t cpuTime, uint64_t activityState)
index f0c9127..06d2787 100644 (file)
@@ -303,9 +303,9 @@ public:
     bool isAlwaysOnLoggingAllowed() const;
     void setActivePopupMenu(WebPopupMenu*);
 
-    void setHiddenPageTimerThrottlingIncreaseLimit(std::chrono::milliseconds limit)
+    void setHiddenPageDOMTimerThrottlingIncreaseLimit(Seconds limit)
     {
-        m_page->setTimerAlignmentIntervalIncreaseLimit(limit);
+        m_page->setDOMTimerAlignmentIntervalIncreaseLimit(limit);
     }
 
 #if ENABLE(INPUT_TYPE_COLOR)
index 015f161..148a913 100644 (file)
@@ -1235,10 +1235,10 @@ void WebProcess::deleteWebsiteDataForOrigins(WebCore::SessionID sessionID, Optio
     }
 }
 
-void WebProcess::setHiddenPageTimerThrottlingIncreaseLimit(int milliseconds)
+void WebProcess::setHiddenPageDOMTimerThrottlingIncreaseLimit(int milliseconds)
 {
     for (auto& page : m_pageMap.values())
-        page->setHiddenPageTimerThrottlingIncreaseLimit(std::chrono::milliseconds(milliseconds));
+        page->setHiddenPageDOMTimerThrottlingIncreaseLimit(Seconds::fromMilliseconds(milliseconds));
 }
 
 #if !PLATFORM(COCOA)
index ef4ed30..01bab3b 100644 (file)
@@ -195,7 +195,7 @@ public:
 
     void updateActivePages();
 
-    void setHiddenPageTimerThrottlingIncreaseLimit(int milliseconds);
+    void setHiddenPageDOMTimerThrottlingIncreaseLimit(int milliseconds);
 
     void processWillSuspendImminently(bool& handled);
     void prepareToSuspend();
index d4041b1..c39ebf3 100644 (file)
@@ -79,7 +79,7 @@ messages -> WebProcess LegacyReceiver {
     DeleteWebsiteData(WebCore::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, std::chrono::system_clock::time_point modifiedSince) -> ()
     DeleteWebsiteDataForOrigins(WebCore::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins) -> ()
 
-    SetHiddenPageTimerThrottlingIncreaseLimit(int milliseconds)
+    SetHiddenPageDOMTimerThrottlingIncreaseLimit(int milliseconds)
     SetProcessSuppressionEnabled(bool flag)
 #if PLATFORM(COCOA)
     SetQOS(int latencyQOS, int throughputQOS)