Migrate some layout timer-related code from std::chrono to Seconds and MonotonicTime
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Nov 2016 02:27:55 +0000 (02:27 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Nov 2016 02:27:55 +0000 (02:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164992

Reviewed by Darin Adler.
Source/WebCore:

std::chrono::milliseconds -> Seconds.

Rename Document::elapsedTime() to timeSinceDocumentCreation() which is more explicit.

Replace INSTRUMENT_LAYOUT_SCHEDULING with LOG(Layout...).

* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::implicitClose):
(WebCore::Document::isLayoutTimerActive):
(WebCore::Document::minimumLayoutDelay):
(WebCore::Document::timeSinceDocumentCreation):
(WebCore::Document::elapsedTime): Deleted.
* dom/Document.h:
* page/ChromeClient.h:
* page/FrameView.cpp:
(WebCore::FrameView::layout):
(WebCore::FrameView::scrollPositionChanged):
(WebCore::FrameView::layoutTimerFired):
(WebCore::FrameView::scheduleRelayout):
(WebCore::FrameView::scheduleRelayoutOfSubtree):
(WebCore::FrameView::unscheduleRelayout):
* page/Settings.cpp:
(WebCore::Settings::setLayoutInterval):
* page/Settings.h:
(WebCore::Settings::layoutInterval):
* style/StyleScope.cpp:
(WebCore::Style::Scope::removePendingSheet):
* workers/WorkerRunLoop.cpp:
(WebCore::WorkerRunLoop::runInMode):

Source/WebKit2:

No more ugly conversion from seconds to milliseconds.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::eventThrottlingDelay):

Source/WTF:

Add Seconds::zero() as a nicer way to express Seconds(0).

* wtf/Seconds.h:
(WTF::Seconds::zero):

Tools:

Use Seconds::zero().

* TestWebKitAPI/Tests/WTF/Condition.cpp:

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

24 files changed:
Source/JavaScriptCore/runtime/AtomicsObject.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/AutomaticThread.cpp
Source/WTF/wtf/Seconds.h
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebCore/style/StyleScope.cpp
Source/WebCore/workers/WorkerRunLoop.cpp
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/ChildProcessProxy.h
Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/Condition.cpp

index 799981a..3d9a4a4 100644 (file)
@@ -315,7 +315,7 @@ EncodedJSValue JSC_HOST_CALL atomicsFuncWait(ExecState* exec)
     // exec->argument(3) returns undefined if it's not provided and ToNumber(undefined) returns NaN,
     // so NaN is the only special case.
     if (timeout == timeout)
-        timeout = std::max(Seconds(0), timeout);
+        timeout = std::max(0_s, timeout);
     else
         timeout = Seconds::infinity();
     
index 9b97c42..c396b33 100644 (file)
@@ -1,5 +1,17 @@
 2016-11-26  Simon Fraser  <simon.fraser@apple.com>
 
+        Migrate some layout timer-related code from std::chrono to Seconds and MonotonicTime
+        https://bugs.webkit.org/show_bug.cgi?id=164992
+
+        Reviewed by Darin Adler.
+
+        Add Seconds::zero() as a nicer way to express Seconds(0). 
+
+        * wtf/Seconds.h:
+        (WTF::Seconds::zero):
+
+2016-11-26  Simon Fraser  <simon.fraser@apple.com>
+
         Add literals for various time units
         https://bugs.webkit.org/show_bug.cgi?id=165074
 
index bd2c7d5..0406f77 100644 (file)
@@ -181,7 +181,7 @@ void AutomaticThread::start(const LockHolder&)
                         RELEASE_ASSERT(result == PollResult::Wait);
                         // Shut the thread down after one second.
                         bool awokenByNotify =
-                            m_condition->m_condition.waitFor(*m_lock, Seconds(1));
+                            m_condition->m_condition.waitFor(*m_lock, 1_s);
                         if (!awokenByNotify) {
                             if (verbose)
                                 dataLog(RawPointer(this), ": Going to sleep!\n");
index 72eed4a..5b8a7a3 100644 (file)
@@ -201,6 +201,8 @@ private:
     double m_value { 0 };
 };
 
+inline namespace seconds_literals {
+
 constexpr Seconds operator"" _min(long double minutes)
 {
     return Seconds::fromMinutes(minutes);
@@ -251,10 +253,13 @@ constexpr Seconds operator"" _ns(unsigned long long nanoseconds)
     return Seconds::fromNanoseconds(nanoseconds);
 }
 
+} // inline seconds_literals
+
 WTF_EXPORT_PRIVATE void sleep(Seconds);
 
-} // namespae WTF
+} // namespace WTF
 
+using namespace WTF::seconds_literals;
 using WTF::Seconds;
 
 #endif // WTF_Seconds_h
index 5552e4c..790bbcd 100644 (file)
@@ -1,5 +1,43 @@
 2016-11-26  Simon Fraser  <simon.fraser@apple.com>
 
+        Migrate some layout timer-related code from std::chrono to Seconds and MonotonicTime
+        https://bugs.webkit.org/show_bug.cgi?id=164992
+
+        Reviewed by Darin Adler.
+
+        std::chrono::milliseconds -> Seconds.
+        
+        Rename Document::elapsedTime() to timeSinceDocumentCreation() which is more explicit.
+        
+        Replace INSTRUMENT_LAYOUT_SCHEDULING with LOG(Layout...).
+
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::implicitClose):
+        (WebCore::Document::isLayoutTimerActive):
+        (WebCore::Document::minimumLayoutDelay):
+        (WebCore::Document::timeSinceDocumentCreation):
+        (WebCore::Document::elapsedTime): Deleted.
+        * dom/Document.h:
+        * page/ChromeClient.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::layout):
+        (WebCore::FrameView::scrollPositionChanged):
+        (WebCore::FrameView::layoutTimerFired):
+        (WebCore::FrameView::scheduleRelayout):
+        (WebCore::FrameView::scheduleRelayoutOfSubtree):
+        (WebCore::FrameView::unscheduleRelayout):
+        * page/Settings.cpp:
+        (WebCore::Settings::setLayoutInterval):
+        * page/Settings.h:
+        (WebCore::Settings::layoutInterval):
+        * style/StyleScope.cpp:
+        (WebCore::Style::Scope::removePendingSheet):
+        * workers/WorkerRunLoop.cpp:
+        (WebCore::WorkerRunLoop::runInMode):
+
+2016-11-26  Simon Fraser  <simon.fraser@apple.com>
+
         Composited negative z-index elements are hidden behind the body sometimes
         https://bugs.webkit.org/show_bug.cgi?id=165080
         rdar://problem/22260229
index c618a9d..dd944f2 100644 (file)
@@ -468,7 +468,7 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
     , m_cssTarget(nullptr)
     , m_processingLoadEvent(false)
     , m_loadEventFinished(false)
-    , m_startTime(std::chrono::steady_clock::now())
+    , m_documentCreationTime(MonotonicTime::now())
     , m_overMinimumLayoutThreshold(false)
     , m_scriptRunner(std::make_unique<ScriptRunner>(*this))
     , m_moduleLoader(std::make_unique<ScriptModuleLoader>(*this))
@@ -2696,7 +2696,7 @@ void Document::implicitClose()
     // fires. This will improve onload scores, and other browsers do it.
     // If they wanna cheat, we can too. -dwh
 
-    if (frame()->navigationScheduler().locationChangePending() && elapsedTime() < settings()->layoutInterval()) {
+    if (frame()->navigationScheduler().locationChangePending() && timeSinceDocumentCreation() < settings()->layoutInterval()) {
         // Just bail out. Before or during the onload we were shifted to another page.
         // The old i-Bench suite does this. When this happens don't bother painting or laying out.        
         m_processingLoadEvent = false;
@@ -2770,26 +2770,24 @@ bool Document::shouldScheduleLayout()
     
 bool Document::isLayoutTimerActive()
 {
-    return view() && view()->layoutPending() && !minimumLayoutDelay().count();
+    return view() && view()->layoutPending() && !minimumLayoutDelay();
 }
 
-std::chrono::milliseconds Document::minimumLayoutDelay()
+Seconds Document::minimumLayoutDelay()
 {
     if (m_overMinimumLayoutThreshold)
-        return 0ms;
+        return 0_s;
     
-    auto elapsed = elapsedTime();
+    auto elapsed = timeSinceDocumentCreation();
     m_overMinimumLayoutThreshold = elapsed > settings()->layoutInterval();
 
     // We'll want to schedule the timer to fire at the minimum layout threshold.
-    return std::max(0ms, settings()->layoutInterval() - elapsed);
+    return std::max(0_s, settings()->layoutInterval() - elapsed);
 }
 
-std::chrono::milliseconds Document::elapsedTime() const
+Seconds Document::timeSinceDocumentCreation() const
 {
-    auto elapsedTime = std::chrono::steady_clock::now() - m_startTime;
-
-    return std::chrono::duration_cast<std::chrono::milliseconds>(elapsedTime);
+    return MonotonicTime::now() - m_documentCreationTime;
 }
 
 void Document::write(const SegmentedString& text, Document* ownerDocument)
index 8f5b43e..a425583 100644 (file)
@@ -671,11 +671,11 @@ public:
     void setReadyState(ReadyState);
     void setParsing(bool);
     bool parsing() const { return m_bParsing; }
-    std::chrono::milliseconds minimumLayoutDelay();
+    Seconds minimumLayoutDelay();
 
     bool shouldScheduleLayout();
     bool isLayoutTimerActive();
-    std::chrono::milliseconds elapsedTime() const;
+    Seconds timeSinceDocumentCreation() const;
     
     void setTextColor(const Color& color) { m_textColor = color; }
     const Color& textColor() const { return m_textColor; }
@@ -1527,7 +1527,7 @@ private:
     bool m_loadEventFinished;
 
     RefPtr<SerializedScriptValue> m_pendingStateObject;
-    std::chrono::steady_clock::time_point m_startTime;
+    MonotonicTime m_documentCreationTime;
     bool m_overMinimumLayoutThreshold;
     
     std::unique_ptr<ScriptRunner> m_scriptRunner;
index 517b1a8..45dbcd2 100644 (file)
@@ -233,7 +233,7 @@ public:
     virtual void didPreventDefaultForEvent() = 0;
 #endif
 
-    virtual Seconds eventThrottlingDelay() { return Seconds(0); };
+    virtual Seconds eventThrottlingDelay() { return 0_s; };
 
 #if PLATFORM(IOS)
     virtual void didReceiveMobileDocType(bool) = 0;
index a619a0b..cbb5289 100644 (file)
@@ -1398,9 +1398,9 @@ void FrameView::layout(bool allowSubtree)
                 }
             }
 
-#ifdef INSTRUMENT_LAYOUT_SCHEDULING
+#if !LOG_DISABLED
             if (m_firstLayout && !frame().ownerElement())
-                printf("Elapsed time before first layout: %lld\n", document.elapsedTime().count());
+                LOG(Layout, "FrameView %p elapsed time before first layout: %.3fs\n", this, document.timeSinceDocumentCreation().value());
 #endif
         }
 
@@ -2437,9 +2437,9 @@ void FrameView::scrollOffsetChangedViaPlatformWidgetImpl(const ScrollOffset& old
 void FrameView::scrollPositionChanged(const ScrollPosition& oldPosition, const ScrollPosition& newPosition)
 {
     Page* page = frame().page();
-    Seconds throttlingDelay = page ? page->chrome().client().eventThrottlingDelay() : Seconds(0);
+    Seconds throttlingDelay = page ? page->chrome().client().eventThrottlingDelay() : 0_s;
 
-    if (throttlingDelay == Seconds(0)) {
+    if (throttlingDelay == 0_s) {
         m_delayedScrollEventTimer.stop();
         sendScrollEvent();
     } else if (!m_delayedScrollEventTimer.isActive())
@@ -2874,9 +2874,9 @@ void FrameView::convertSubtreeLayoutToFullLayout()
 
 void FrameView::layoutTimerFired()
 {
-#ifdef INSTRUMENT_LAYOUT_SCHEDULING
+#if !LOG_DISABLED
     if (!frame().document()->ownerElement())
-        printf("Layout timer fired at %lld\n", frame().document()->elapsedTime().count());
+        LOG(Layout, "FrameView %p layout timer fired at %.3fs", this, frame().document()->timeSinceDocumentCreation().value());
 #endif
     layout();
 }
@@ -2901,17 +2901,18 @@ void FrameView::scheduleRelayout()
     if (frame().ownerRenderer() && isInChildFrameWithFrameFlattening())
         frame().ownerRenderer()->setNeedsLayout(MarkContainingBlockChain);
 
-    std::chrono::milliseconds delay = frame().document()->minimumLayoutDelay();
-    if (m_layoutTimer.isActive() && m_delayedLayout && !delay.count())
+    Seconds delay = frame().document()->minimumLayoutDelay();
+    if (m_layoutTimer.isActive() && m_delayedLayout && !delay)
         unscheduleRelayout();
+
     if (m_layoutTimer.isActive())
         return;
 
-    m_delayedLayout = delay.count();
+    m_delayedLayout = delay.value();
 
-#ifdef INSTRUMENT_LAYOUT_SCHEDULING
+#if !LOG_DISABLED
     if (!frame().document()->ownerElement())
-        printf("Scheduling layout for %d\n", delay);
+        LOG(Layout, "FrameView %p scheduling layout for %.3fs", this, delay.value());
 #endif
 
     m_layoutTimer.startOneShot(delay);
@@ -2944,11 +2945,11 @@ void FrameView::scheduleRelayoutOfSubtree(RenderElement& newRelayoutRoot)
     }
 
     if (!layoutPending() && m_layoutSchedulingEnabled) {
-        std::chrono::milliseconds delay = renderView.document().minimumLayoutDelay();
+        Seconds delay = renderView.document().minimumLayoutDelay();
         ASSERT(!newRelayoutRoot.container() || is<RenderView>(newRelayoutRoot.container()) || !newRelayoutRoot.container()->needsLayout());
         m_layoutRoot = &newRelayoutRoot;
         InspectorInstrumentation::didInvalidateLayout(frame());
-        m_delayedLayout = delay.count();
+        m_delayedLayout = delay.value();
         m_layoutTimer.startOneShot(delay);
         return;
     }
@@ -3041,9 +3042,9 @@ void FrameView::unscheduleRelayout()
     if (!m_layoutTimer.isActive())
         return;
 
-#ifdef INSTRUMENT_LAYOUT_SCHEDULING
+#if !LOG_DISABLED
     if (!frame().document()->ownerElement())
-        printf("Layout timer unscheduled at %d\n", frame().document()->elapsedTime());
+        LOG(Layout, "FrameView %p layout timer unscheduled at %.3fs", this, frame().document()->timeSinceDocumentCreation().value());
 #endif
     
     m_layoutTimer.stop();
index 6ec306d..49175fb 100644 (file)
@@ -184,7 +184,7 @@ static const bool defaultSelectTrailingWhitespaceEnabled = false;
 // This amount of time must have elapsed before we will even consider scheduling a layout without a delay.
 // FIXME: For faster machines this value can really be lowered to 200. 250 is adequate, but a little high
 // for dual G5s. :)
-static const auto layoutScheduleThreshold = 250ms;
+static const Seconds layoutScheduleThreshold = 250_ms;
 
 Settings::Settings(Page* page)
     : m_page(nullptr)
@@ -461,7 +461,7 @@ void Settings::setMinimumDOMTimerInterval(std::chrono::milliseconds interval)
     }
 }
 
-void Settings::setLayoutInterval(std::chrono::milliseconds layoutInterval)
+void Settings::setLayoutInterval(Seconds layoutInterval)
 {
     // FIXME: It seems weird that this function may disregard the specified layout interval.
     // We should either expose layoutScheduleThreshold or better communicate this invariant.
index d06957d..0a957ef 100644 (file)
@@ -172,8 +172,8 @@ public:
     WEBCORE_EXPORT void setMinimumDOMTimerInterval(std::chrono::milliseconds); // Initialized to DOMTimer::defaultMinimumInterval().
     std::chrono::milliseconds minimumDOMTimerInterval() const { return m_minimumDOMTimerInterval; }
 
-    WEBCORE_EXPORT void setLayoutInterval(std::chrono::milliseconds);
-    std::chrono::milliseconds layoutInterval() const { return m_layoutInterval; }
+    WEBCORE_EXPORT void setLayoutInterval(Seconds);
+    Seconds layoutInterval() const { return m_layoutInterval; }
 
     bool hiddenPageDOMTimerThrottlingEnabled() const { return m_hiddenPageDOMTimerThrottlingEnabled; }
     WEBCORE_EXPORT void setHiddenPageDOMTimerThrottlingEnabled(bool);
@@ -325,7 +325,7 @@ private:
     URL m_userStyleSheetLocation;
     const std::unique_ptr<FontGenericFamilies> m_fontGenericFamilies;
     SecurityOrigin::StorageBlockingPolicy m_storageBlockingPolicy;
-    std::chrono::milliseconds m_layoutInterval;
+    Seconds m_layoutInterval;
     std::chrono::milliseconds m_minimumDOMTimerInterval;
 
     SETTINGS_MEMBER_VARIABLES
index b0bba4e..82270ad 100644 (file)
@@ -149,12 +149,6 @@ void Scope::removePendingSheet(RemovePendingSheetNotificationType notification)
     ASSERT(m_pendingStyleSheetCount > 0);
 
     m_pendingStyleSheetCount--;
-    
-#ifdef INSTRUMENT_LAYOUT_SCHEDULING
-    if (!ownerElement())
-        printf("Stylesheet loaded at time %d. %d stylesheets still remain.\n", elapsedTime(), m_pendingStylesheets);
-#endif
-
     if (m_pendingStyleSheetCount)
         return;
 
index 65685d7..b32b259 100644 (file)
@@ -163,8 +163,7 @@ MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerGlobalScope* context, cons
 #if USE(CF)
     CFAbsoluteTime nextCFRunLoopTimerFireDate = CFRunLoopGetNextTimerFireDate(CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
     double timeUntilNextCFRunLoopTimerInSeconds = nextCFRunLoopTimerFireDate - CFAbsoluteTimeGetCurrent();
-    deadline = WallTime::now() + std::max(
-        Seconds(0), Seconds(timeUntilNextCFRunLoopTimerInSeconds));
+    deadline = WallTime::now() + std::max(0_s, Seconds(timeUntilNextCFRunLoopTimerInSeconds));
 #endif
 
     WallTime absoluteTime;
index f915f70..5ab34a6 100644 (file)
@@ -339,8 +339,8 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 - (BOOL)_alwaysRequestGeolocationPermission;
 - (void)_setAlwaysUseAcceleratedOverflowScroll:(BOOL)flag;
 - (BOOL)_alwaysUseAcceleratedOverflowScroll;
-- (void)_setLayoutInterval:(int)l;
-- (int)_layoutInterval;
+- (void)_setLayoutInterval:(int)milliseconds;
+- (int)_layoutInterval; // Milliseonds.
 - (void)_setMaxParseDuration:(float)d;
 - (float)_maxParseDuration;
 - (void)_setInterpolationQuality:(int)quality;
index 8e471b1..8894d86 100644 (file)
@@ -2736,7 +2736,7 @@ static bool needsSelfRetainWhileLoadingQuirk()
     settings.setStandalone([preferences _standalone]);
     settings.setTelephoneNumberParsingEnabled([preferences _telephoneNumberParsingEnabled]);
     settings.setAllowMultiElementImplicitSubmission([preferences _allowMultiElementImplicitFormSubmission]);
-    settings.setLayoutInterval(std::chrono::milliseconds([preferences _layoutInterval]));
+    settings.setLayoutInterval(Seconds::fromMilliseconds([preferences _layoutInterval]));
     settings.setMaxParseDuration([preferences _maxParseDuration]);
     settings.setAlwaysUseAcceleratedOverflowScroll([preferences _alwaysUseAcceleratedOverflowScroll]);
     settings.setAudioSessionCategoryOverride([preferences audioSessionCategoryOverride]);
index 230dd22..206daa5 100644 (file)
@@ -1,3 +1,17 @@
+2016-11-26  Simon Fraser  <simon.fraser@apple.com>
+
+        Migrate some layout timer-related code from std::chrono to Seconds and MonotonicTime
+        https://bugs.webkit.org/show_bug.cgi?id=164992
+
+        Reviewed by Darin Adler.
+        
+        No more ugly conversion from seconds to milliseconds.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::eventThrottlingDelay):
+
 2016-11-25  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Follow-up fixes to r208974
index 95ff5f0..4584eb8 100644 (file)
@@ -44,7 +44,7 @@ public:
     void terminate();
 
     template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<IPC::SendOption> sendOptions = { });
-    template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, Seconds timeout = Seconds(1), OptionSet<IPC::SendSyncOption> sendSyncOptions = { });
+    template<typename T> bool sendSync(T&& message, typename T::Reply&&, uint64_t destinationID, Seconds timeout = 1_s, OptionSet<IPC::SendSyncOption> sendSyncOptions = { });
 
     IPC::Connection* connection() const
     {
index 88ccca5..994344f 100644 (file)
@@ -366,7 +366,7 @@ void NetworkProcessProxy::sendProcessWillSuspendImminently()
         return;
 
     bool handled = false;
-    sendSync(Messages::NetworkProcess::ProcessWillSuspendImminently(), Messages::NetworkProcess::ProcessWillSuspendImminently::Reply(handled), 0, Seconds(1));
+    sendSync(Messages::NetworkProcess::ProcessWillSuspendImminently(), Messages::NetworkProcess::ProcessWillSuspendImminently::Reply(handled), 0, 1_s);
 }
     
 void NetworkProcessProxy::sendPrepareToSuspend()
index aeaab44..0787e2e 100644 (file)
@@ -900,7 +900,7 @@ void WebProcessProxy::sendProcessWillSuspendImminently()
         return;
 
     bool handled = false;
-    sendSync(Messages::WebProcess::ProcessWillSuspendImminently(), Messages::WebProcess::ProcessWillSuspendImminently::Reply(handled), 0, Seconds(1));
+    sendSync(Messages::WebProcess::ProcessWillSuspendImminently(), Messages::WebProcess::ProcessWillSuspendImminently::Reply(handled), 0, 1_s);
 }
 
 void WebProcessProxy::sendPrepareToSuspend()
index 73c9d99..7b7bd48 100644 (file)
@@ -313,7 +313,7 @@ void WebPageProxy::synchronizeDynamicViewportUpdate()
         double newScale;
         FloatPoint newScrollPosition;
         uint64_t nextValidLayerTreeTransactionID;
-        if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition, nextValidLayerTreeTransactionID), m_pageID, Seconds(2))) {
+        if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition, nextValidLayerTreeTransactionID), m_pageID, 2_s)) {
             m_dynamicViewportSizeUpdateWaitingForTarget = false;
             m_dynamicViewportSizeUpdateLayerTreeTransactionID = nextValidLayerTreeTransactionID;
             m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, nextValidLayerTreeTransactionID);
index d950183..c95015f 100644 (file)
@@ -3112,7 +3112,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings.setPasswordEchoEnabled(store.getBoolValueForKey(WebPreferencesKey::passwordEchoEnabledKey()));
     settings.setPasswordEchoDurationInSeconds(store.getDoubleValueForKey(WebPreferencesKey::passwordEchoDurationKey()));
     
-    settings.setLayoutInterval(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::duration<double>(store.getDoubleValueForKey(WebPreferencesKey::layoutIntervalKey()))));
+    settings.setLayoutInterval(Seconds(store.getDoubleValueForKey(WebPreferencesKey::layoutIntervalKey())));
     settings.setMaxParseDuration(store.getDoubleValueForKey(WebPreferencesKey::maxParseDurationKey()));
 
     settings.setEnableInheritURIQueryComponent(store.getBoolValueForKey(WebPreferencesKey::enableInheritURIQueryComponentKey()));
index ebabcda..48ce77e 100644 (file)
@@ -2128,16 +2128,16 @@ Seconds WebPage::eventThrottlingDelay() const
     if (behaviorOverride) {
         switch (behaviorOverride.value()) {
         case EventThrottlingBehavior::Responsive:
-            return Seconds(0);
+            return 0_s;
         case EventThrottlingBehavior::Unresponsive:
-            return Seconds(1);
+            return 1_s;
         }
     }
 
     if (m_isInStableState || m_estimatedLatency <= Seconds(1.0 / 60))
-        return Seconds(0);
+        return 0_s;
 
-    return Seconds(std::min<double>(m_estimatedLatency.value() * 2, 1));
+    return std::min(m_estimatedLatency.value() * 2, 1_s);
 }
 
 void WebPage::syncApplyAutocorrection(const String& correction, const String& originalText, bool& correctionApplied)
index 50504fd..ff506d6 100644 (file)
@@ -1,5 +1,16 @@
 2016-11-26  Simon Fraser  <simon.fraser@apple.com>
 
+        Migrate some layout timer-related code from std::chrono to Seconds and MonotonicTime
+        https://bugs.webkit.org/show_bug.cgi?id=164992
+
+        Reviewed by Darin Adler.
+        
+        Use Seconds::zero().
+
+        * TestWebKitAPI/Tests/WTF/Condition.cpp:
+
+2016-11-26  Simon Fraser  <simon.fraser@apple.com>
+
         Add literals for various time units
         https://bugs.webkit.org/show_bug.cgi?id=165074
 
index ee31d6a..8485273 100644 (file)
@@ -81,7 +81,7 @@ void runTest(
     unsigned numMessagesPerProducer,
     NotifyStyle notifyStyle,
     Seconds timeout = Seconds::infinity(),
-    Seconds delay = Seconds(0))
+    Seconds delay = 0_s)
 {
     Deque<unsigned> queue;
     bool shouldContinue = true;